We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 80dfba5 commit c9e67b7Copy full SHA for c9e67b7
src/app.ts
@@ -0,0 +1,20 @@
1
+import express from 'express'
2
+import morgan from 'morgan'
3
+
4
+const app = express()
5
6
+//Settings
7
+app.set('port', 3000)
8
9
+//Middlewares
10
+app.use(morgan('dev'))
11
+app.use(express.json())
12
+app.use(express.urlencoded({extended: false}))
13
14
+//Routes
15
+app.get('/', (req,res)=>{
16
+ res.send(`The API is at http://127.0.0.1:${app.get('port')}`)
17
+})
18
19
+export default app
20
src/index.ts
@@ -1 +1,9 @@
-console.log('Hello World!')
+import app from './app'
+function main() {
+ app.listen(app.get('port'))
+ console.log('Server running in port: ', app.get('port'))
+}
+main()
0 commit comments