Starting the node server

Now let's create a server. We should create an app.kt file under the backend module at the backend/src/kotlin path. Refer to the source code to verify. Write the following piece of code in app.kt:

    external fun require(module: String): dynamic    external val process: dynamic    external val __dirname: dynamic    fun main(args: Array<String>) {      println("Server Starting!")      val express = require("express")      val app = express()      val path = require("path")      val http = require("http")      /**       * Get port from environment and store in Express.       */      val port = normalizePort(process.env.PORT)      app.set("port", port)      // view engine setup      app.set("views", path.join(__dirname, "../../webapp"))      app.set("view engine", "ejs")      app.use(express.static ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.