https://github.com/shubhamd99/nodejs-express-typescript
NodeJS Express Typescript
https://github.com/shubhamd99/nodejs-express-typescript
express express-handlebars express-middleware nodejs typescript
Last synced: 4 months ago
JSON representation
NodeJS Express Typescript
- Host: GitHub
- URL: https://github.com/shubhamd99/nodejs-express-typescript
- Owner: shubhamd99
- Created: 2019-06-24T01:29:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T19:59:57.000Z (over 2 years ago)
- Last Synced: 2025-01-09T15:19:27.089Z (6 months ago)
- Topics: express, express-handlebars, express-middleware, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 249 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Setup (Node Express Typescript)
1. tsc --init (es6, outDir - /dist, rootDir - /src, moduleResolution: node)
2. npm init -y
3. npm i express
4. npm i -D typescript ts-node nodemon @types/node @types/express (dev dependency)
5. add these scripts to package.json:```
"start": "node dist/app.js",
"dev": "nodemon src/app.ts",
"build": "tsc -p ."
```
6. npm run dev## Stuff
1. For importing few static files in nodejs
```
app.get('/', (req: Request, res: Response, next: NextFunction) => {
res.sendFile(path.join(__dirname, '../public', 'index.html'));
});
```
2. For multiple static imports in nodejs
```
app.use(express.static(path.join(__dirname, '../public')))
```