Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 2 days 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 (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T19:59:57.000Z (almost 2 years ago)
- Last Synced: 2023-03-07T11:12:05.877Z (over 1 year ago)
- Topics: express, express-handlebars, express-middleware, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 249 KB
- Stars: 0
- Watchers: 1
- 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')))
```![alt_img](https://i.imgur.com/VUj4A28.png)