-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
40 lines (35 loc) · 947 Bytes
/
app.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import "reflect-metadata";
import express = require("express");
import { createConnection } from "typeorm";
import { Server, Path, GET, PathParam, PassportAuthenticator, POST } from "typescript-rest";
import { UserRoute } from "./routes/userRoute"
import { User } from "./models/user"
import { Content } from "./models/content"
let server: express.Application = express();
@Path("/")
class Default {
@GET
explain(): string {
return "typescript api"
}
}
Server.buildServices(server, Default, UserRoute, );
// configure test and production environments
createConnection({
type: "postgres",
host: "localhost",
port: 5432,
username: "user",
password: "pass",
database: "typescript_api",
entities: [
User,
Content
],
synchronize: true,
logging: false
})
server.listen(8080, () => {
console.log(`server started at http://localhost:${8080}`);
});
export default server;