1.0.3 ā¢ Published 5 months ago
typescript-express-basic v1.0.3
Basic api concept using typescript for express.
https://www.npmjs.com/package/typescript-express-basic
š Homepage
Concept
Install
Install express from https://expressjs.com/
npm install express --save
Install extend express basic
npm install typescript-express-basic --save
Creating example controller
Example file: https://github.com/vosonha89/typescript-express-basic/blob/main/test/src/controllers/publicController.ts
export class PublicController extends ApiController {
public controllerName = 'public';
@ApiRoute({
method: ApiMethod.GET,
path: '/get'
})
public get(req: Request, res: Response): void {
const id = req.query.id;
res.status(StatusCode.Ok);
res.send('Public get ' + id);
}
}
Register app & controllers
Example file: https://github.com/vosonha89/typescript-express-basic/blob/main/test/src/index.ts
const port = 3000;
let app = apiExpress;
app.use(express.json());
// Register controller
app.registerController(new PublicController());
app.listen(port, () => {
console.log(`[server]: Server is running at http://localhost:${port}`);
});
Run test project
npm run test
Link: http://localhost:3000
Author
š¤ vosonha89
- Github: @vosonha89
- LinkedIn: @https:\/\/www.linkedin.com\/in\/vo-son-ha\/
š¤ Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.
Show your support
Give a āļø if this project helped you!
š License
Copyright Ā© 2024 vosonha89. This project is MIT licensed.
This README was generated with ā¤ļø by readme-md-generator