-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.es.js
More file actions
34 lines (27 loc) · 1.02 KB
/
index.es.js
File metadata and controls
34 lines (27 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Express documentation - https://expressjs.com/en/api.html
// Express.js Alternatives - https://betterstack.com/community/guides/scaling-nodejs/expressjs-alternatives
import http from 'http'
import { json // parser
, Router // router
, default as express // server
} from 'express'
import log from './logger.js'
const
{ METHODS } = http
, { PORT = 3000 } = process.env
console.log ( METHODS )
export default class Resource extends Router {
constructor() {
super ( { strict: true, caseSensitivity: true, mergeParams: true } )
// .route ( '/' )
.get ( '/', ( req, res ) => res.json ( { data: 'SHEESH' } ) )
.get ( '/welcome', ( req, res ) =>
res.send ( '<h1>Hello</h1> welcome to my http server made with express' ) )
} // custructor
} // Resource
const app = ( new Resource )
.use ( log ( 'foo.log' ) )
.use ( ( req, res, next ) => res.status ( 404 ).send ( "That route doesn't exist" ) )
void ( new express () )
.use( app )
.listen ( PORT, _ => console.log ( `Listening on port ${PORT}` ) )