File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 22
33Implements the Expressjs Hello World example to provide faster start deploying on Cyclic platform
44
5-
65## Installation
76
87- Fork this repo
Original file line number Diff line number Diff line change 11const express = require ( 'express' )
22const app = express ( )
3+ const fs = require ( 'fs' )
4+
5+ const VERSION_FILENAME = './.git/refs/heads/main'
36
47app . get ( '/' , ( req , res ) => {
58 console . log ( '[hello-world] root handler called' )
69 res
710 . set ( 'x-powered-by' , 'cyclic.sh' )
8- . send ( 'Hello World!' )
11+ . send ( '<h1> Hello World!</h1> ' )
912 . end ( )
1013} )
1114
1215app . use ( '*' , ( req , res ) => {
1316 console . log ( '[hello-world] Star handler called' )
17+ let version = 'unknown'
18+ if ( fs . existsSync ( VERSION_FILENAME ) ) {
19+ version = fs . readFileSync ( VERSION_FILENAME ) . toString ( )
20+ }
1421 res
1522 . set ( 'x-powered-by' , 'cyclic.sh' )
1623 . json ( {
1724 msg : "Not strickly part of the hello world but you get the picture." ,
25+ version,
1826 at : new Date ( ) . toISOString ( ) ,
1927 method : req . method ,
2028 hostname : req . hostname ,
You can’t perform that action at this time.
0 commit comments