This repository was archived by the owner on Jul 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
60 lines (53 loc) · 1.33 KB
/
index.ts
File metadata and controls
60 lines (53 loc) · 1.33 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// import * as express from "express";
// const app = express();
// app.get("*", (req, res) => {
// res.write(
// "<h1><marquee direction=right>Hello from Express path `/` on Now 2.0!</marquee></h1>"
// );
// res.write('<h2>Go to <a href="/about">/about</a></h2>');
// res.end();
// });
import * as express from "express";
import {
Context,
ServiceContext,
Server,
Path,
GET,
PathParam,
FileParam,
FilesParam,
POST
} from "typescript-rest";
@Path("/")
class AboutService {
@GET
getAbout(
@Context
context: ServiceContext
): void {
console.log("req", context.request);
console.log("res", context.response);
context.response.write(
"<h1><marquee direction=left>Hellos-get from Express path `/about` on Now 2.0!</marquee></h1>"
);
context.response.write('<h2>Go to <a href="/">/</a></h2>');
context.response.end();
}
@POST
postAbout(
@Context
context: ServiceContext,
@FilesParam("json") file: Express.Multer.File
) {
console.log("GREGGGGG");
console.log("req", context.request);
console.log("req.body", context.request.body);
// console.log("file", file);
console.log("res", context.response);
context.response.send("Hello API Event Received");
}
}
let app: express.Application = express();
Server.buildServices(app);
module.exports = app;