cubetiq-express-server/README.md

55 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

# CUBETIQ Express Server
2021-09-26 20:55:50 +07:00
[![Build Status](https://dci.osa.cubetiqs.com/api/badges/CUBETIQ/cubetiq-express-server/status.svg)](https://dci.osa.cubetiqs.com/CUBETIQ/cubetiq-express-server)
2021-09-16 17:23:07 +07:00
- Express
- TypeScript
- Decorators
# Getting Start
- Add code into your `index.ts`
```ts
import "reflect-metadata"
import { createServer } from "http"
import server from "./server"
const app = server.instance
const httpServer = createServer(app)
httpServer.listen(process.env.PORT || 3000, () => {
console.log(`Server listening on port: 3000`)
})
```
- Create `server.ts`
```ts
import { Request, Response } from "express"
import { Application } from "./application"
import { Controller, Get } from "./decorators"
@Controller("/index")
class IndexController {
@Get()
public async index(req: Request, res: Response) {
res.json({
status: 200,
})
}
}
class Server extends Application {
get controllers(): any[] {
return [IndexController]
}
}
export default new Server()
```
2021-09-16 17:23:07 +07:00
### Contributors
- Sambo Chea <sombochea@cubetiqs.com>