Last active
April 2, 2020 04:46
-
-
Save steren/5d5592e1b8b308d152626d33e6b076cc to your computer and use it in GitHub Desktop.
TypeScript to JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "hello-ts", | |
"version": "1.0.0", | |
"description": "Hello TS", | |
"scripts": { | |
"start": "node server.js", | |
"gcp-build": "npm run build", | |
"build": "tsc server.ts" | |
}, | |
"author": "Steren <steren@google.com>", | |
"license": "Apache-2.0", | |
"dependencies": { | |
"express": "^4.16.2" | |
}, | |
"devDependencies": { | |
"typescript": "^2.9.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare var require: any | |
declare var process: { | |
env: { | |
PORT: string | |
} | |
}; | |
const express = require('express'); | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.send('🎉 Hello TypeScript! 🎉'); | |
}); | |
const server = app.listen(process.env.PORT || 8080, () => { | |
const host = server.address().address; | |
const port = server.address().port; | |
console.log(`Example app listening at http://${host}:${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment