typespeed 2.4.11 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +8 -2
  2. package/dist/bind.decorator.js +50 -0
  3. package/dist/core.decorator.js +113 -26
  4. package/dist/database.decorator.js +122 -16
  5. package/dist/decorator-utils.js +42 -0
  6. package/dist/default/rabbitmq.class.js +18 -1
  7. package/dist/default/redis.class.js +14 -1
  8. package/dist/default/socket-io.class.js +53 -4
  9. package/dist/route.decorator.js +175 -10
  10. package/dist/typespeed.d.ts +35 -31
  11. package/dist/typespeed.js +31 -3
  12. package/package.json +6 -2
  13. package/.github/workflows/test.yml +0 -50
  14. package/app/nodemon.json +0 -5
  15. package/app/package.json +0 -17
  16. package/app/src/aop-test.class.ts +0 -29
  17. package/app/src/config-development.json +0 -26
  18. package/app/src/config-production.json +0 -15
  19. package/app/src/config.json +0 -50
  20. package/app/src/custom-log.class.ts +0 -33
  21. package/app/src/entities/mutil-users.class.ts +0 -5
  22. package/app/src/entities/user-dto.class.ts +0 -3
  23. package/app/src/first-page.class.ts +0 -46
  24. package/app/src/jwt-authentication.class.ts +0 -30
  25. package/app/src/main.ts +0 -24
  26. package/app/src/second-page.class.ts +0 -43
  27. package/app/src/test-database.class.ts +0 -81
  28. package/app/src/test-log.class.ts +0 -11
  29. package/app/src/test-mq.class.ts +0 -21
  30. package/app/src/test-orm.class.ts +0 -63
  31. package/app/src/test-redis.class.ts +0 -45
  32. package/app/src/test-request.class.ts +0 -37
  33. package/app/src/test-socket.class.ts +0 -56
  34. package/app/src/user-model.class.ts +0 -50
  35. package/app/src/views/index.html +0 -1
  36. package/app/src/views/socket.html +0 -23
  37. package/app/src/views/upload.html +0 -14
  38. package/app/static/favicon.ico +0 -0
  39. package/app/static/k.jpg +0 -0
  40. package/app/tsconfig.json +0 -20
  41. package/introduction/decorator/example-import.class.ts +0 -6
  42. package/introduction/decorator/main-app.ts +0 -6
  43. package/introduction/decorator/main-decorator.ts +0 -108
  44. package/introduction/decorator/main-import.ts +0 -1
  45. package/introduction/decorator/main-reflect.ts +0 -25
  46. package/introduction/tsconfig.json +0 -20
  47. package/introduction/web-services/db-init.ts +0 -39
  48. package/introduction/web-services/db-singleton.ts +0 -59
  49. package/introduction/web-services/http-if.ts +0 -10
  50. package/introduction/web-services/http-init.ts +0 -6
  51. package/introduction/web-services/http-router.ts +0 -28
  52. package/src/core.decorator.ts +0 -98
  53. package/src/database.decorator.ts +0 -342
  54. package/src/default/default-authentication.class.ts +0 -10
  55. package/src/default/express-server.class.ts +0 -150
  56. package/src/default/log-default.class.ts +0 -9
  57. package/src/default/node-cache.class.ts +0 -40
  58. package/src/default/pages/404.html +0 -226
  59. package/src/default/pages/500.html +0 -713
  60. package/src/default/rabbitmq.class.ts +0 -61
  61. package/src/default/read-write-db.class.ts +0 -53
  62. package/src/default/redis.class.ts +0 -79
  63. package/src/default/socket-io.class.ts +0 -81
  64. package/src/factory/authentication-factory.class.ts +0 -9
  65. package/src/factory/cache-factory.class.ts +0 -7
  66. package/src/factory/data-source-factory.class.ts +0 -4
  67. package/src/factory/log-factory.class.ts +0 -8
  68. package/src/factory/server-factory.class.ts +0 -6
  69. package/src/route.decorator.ts +0 -175
  70. package/src/scaffold/command.ts +0 -40
  71. package/src/scaffold/templates/front-page.class.ts.tpl +0 -12
  72. package/src/scaffold/templates/main.ts.tpl +0 -13
  73. package/src/scaffold/templates/nodemon.json.tpl +0 -7
  74. package/src/scaffold/templates/package.json.tpl +0 -16
  75. package/src/scaffold/templates/tsconfig.json.tpl +0 -17
  76. package/src/typespeed.d.ts +0 -399
  77. package/src/typespeed.ts +0 -110
  78. package/test/database.test.ts +0 -76
  79. package/test/first-page.test.ts +0 -42
  80. package/test/hooks.ts +0 -13
  81. package/test/mq.test.ts +0 -17
  82. package/test/orm.test.ts +0 -66
  83. package/test/redis.test.ts +0 -48
  84. package/test/request.test.ts +0 -51
  85. package/test/second-page.test.ts +0 -50
  86. package/test/socket.test.ts +0 -60
  87. package/test-env/docker-compose.test.yml +0 -31
  88. package/test-env/mysql-init/init.sql +0 -8
  89. package/test-env//346/234/254/345/234/260Docker/346/265/213/350/257/225/346/226/271/346/241/210.md +0 -69
  90. package/tsconfig.json +0 -25
@@ -1,61 +0,0 @@
1
- import { bean, getComponent } from "../core.decorator";
2
- import { config } from "../typespeed";
3
- import { connect } from "amqplib";
4
- let rabbitConnection = null;
5
-
6
- class RabbitMQ {
7
-
8
- @bean
9
- public getRabbitMQ(): RabbitMQ {
10
- if (!config("rabbitmq")) {
11
- return null;
12
- }
13
- return new RabbitMQ();
14
- }
15
-
16
- public async publishMessageToExchange(exchange: string, routingKey: string, message: string): Promise<void> {
17
- const channel = await getChannel();
18
- await channel.assertExchange(exchange);
19
- channel.publish(exchange, routingKey, Buffer.from(message));
20
- await channel.close();
21
- }
22
-
23
- public async sendMessageToQueue(queue: string, message: string): Promise<void> {
24
- const channel = await getChannel();
25
- await channel.accertQueue(queue);
26
- channel.sendToQueue(queue, Buffer.from(message));
27
- await channel.close();
28
- }
29
-
30
- public async publish(exchange: string, routingKey: string, message: string): Promise<void> {
31
- await this.publishMessageToExchange(exchange, routingKey, message);
32
- }
33
-
34
- public async send(queue: string, message: string): Promise<void> {
35
- await this.sendMessageToQueue(queue, message);
36
- }
37
- }
38
-
39
- async function getChannel() {
40
- if (rabbitConnection === null) {
41
- rabbitConnection = await connect(config("rabbitmq"));
42
- process.once('SIGINT', async () => {
43
- await rabbitConnection.close();
44
- });
45
- }
46
- const channel = await rabbitConnection.createChannel();
47
- return channel;
48
- }
49
-
50
- function rabbitListener(queue: string) {
51
- return (target: any, propertyKey: string) => {
52
- (async function () {
53
- const channel = await getChannel();
54
- await channel.assertQueue(queue);
55
- const targetBean = getComponent(target.constructor);
56
- await channel.consume(queue, targetBean[propertyKey], { noAck: true });
57
- }());
58
- }
59
- }
60
-
61
- export { RabbitMQ, rabbitListener };
@@ -1,53 +0,0 @@
1
- import { createConnection, createPool } from "mysql2";
2
- import DataSourceFactory from "../factory/data-source-factory.class";
3
- import { bean } from "../core.decorator";
4
- import { config } from "../typespeed";
5
- export default class ReadWriteDb extends DataSourceFactory {
6
- private readonly readSession;
7
- private readonly writeSession;
8
-
9
- @bean
10
- public getDataSource(): DataSourceFactory {
11
- if (!config("mysql")) {
12
- return null;
13
- }
14
- return new ReadWriteDb();
15
- }
16
-
17
- constructor() {
18
- super();
19
- const dbConfig = config("mysql");
20
- if (dbConfig["master"] && dbConfig["slave"]) {
21
- this.writeSession = this.getConnectionByConfig(dbConfig["master"]);
22
- if (Array.isArray(dbConfig["slave"])) {
23
- this.readSession = dbConfig["slave"].map(config => this.getConnectionByConfig(config));
24
- } else {
25
- this.readSession = [this.getConnectionByConfig(dbConfig["slave"])];
26
- }
27
- } else {
28
- this.writeSession = this.getConnectionByConfig(dbConfig);
29
- this.readSession = [this.writeSession];
30
- }
31
- }
32
-
33
- private getConnectionByConfig(config: object) {
34
- if (config["PoolOptions"] !== undefined) {
35
- // we need pool
36
- if (Object.keys(config["PoolOptions"]).length !== 0) {
37
- config = Object.assign(config, config["PoolOptions"]);
38
- }
39
- return createPool(config).promise();
40
- } else {
41
- // only connection
42
- return createConnection(config).promise();
43
- }
44
- }
45
-
46
- public readConnection() {
47
- return this.readSession[Math.floor(Math.random() * this.readSession.length)];
48
- }
49
-
50
- public writeConnection() {
51
- return this.writeSession;
52
- }
53
- }
@@ -1,79 +0,0 @@
1
- import { bean, getComponent } from "../core.decorator";
2
- import { default as IoRedis, RedisKey} from "ioredis";
3
- import { config } from "../typespeed";
4
- const redisSubscribers = {};
5
-
6
- class Redis extends IoRedis {
7
- private static pubObj: Redis = null;
8
- private static subObj: Redis = null;
9
-
10
- @bean
11
- public getRedis(): Redis {
12
- return Redis.getInstanceOfRedis("pub");
13
- }
14
-
15
- public async zrevranking(key: RedisKey, start: number | string, stop: number | string): Promise<Map<string, number>> {
16
- const list = await this.zrevrange(key, start, stop, "WITHSCORES");
17
- const map = new Map<string, number>();
18
- for (let i = 0; i < list.length; i = i + 2) {
19
- map.set(list[i], Number(list[i + 1]));
20
- }
21
- return map;
22
- }
23
-
24
- public async zranking(key: RedisKey, start: number | string, stop: number | string): Promise<Map<string, number>> {
25
- const list = await this.zrange(key, start, stop, "WITHSCORES");
26
- const map = new Map<string, number>();
27
- for (let i = 0; i < list.length; i = i + 2) {
28
- map.set(list[i], Number(list[i + 1]));
29
- }
30
- return map;
31
- }
32
-
33
- static getInstanceOfRedis(mode: "sub" | "pub") {
34
- if (!config("redis")) {
35
- return null;
36
- }
37
- if (mode === "pub") {
38
- this.pubObj = this.pubObj || new Redis(config("redis"));
39
- return this.pubObj;
40
- } else {
41
- this.subObj = this.subObj || new Redis(config("redis"));
42
- return this.subObj;
43
- }
44
- }
45
-
46
- static async close() {
47
- if(this.subObj != null) { await this.subObj.quit(); }
48
- if(this.pubObj != null) { await this.pubObj.quit(); }
49
- }
50
- }
51
-
52
- function redisSubscriber(channel: string) {
53
- if (!config("redis")) return function(){
54
- throw new Error("redis not configured");
55
- };
56
- Redis.getInstanceOfRedis("sub").subscribe(channel, function (err, count) {
57
- if (err) {
58
- console.error(err);
59
- }
60
- });
61
- return function (target: any, propertyKey: string) {
62
- redisSubscribers[channel] = {
63
- target: target,
64
- propertyKey: propertyKey
65
- };
66
- };
67
- }
68
-
69
- if (config("redis")) {
70
- Redis.getInstanceOfRedis("sub").on("message", async function (channel, message) {
71
- await getComponent(redisSubscribers[channel].target.constructor)[redisSubscribers[channel].propertyKey](message);
72
- });
73
- }
74
-
75
- process.once('SIGINT', () => {
76
- Redis.close();
77
- });
78
-
79
- export { Redis, redisSubscriber };
@@ -1,81 +0,0 @@
1
- import { Server as IoServer } from "socket.io";
2
- import { createServer } from "http";
3
- import { getComponent } from "../core.decorator";
4
-
5
- let io: IoServer = null;
6
- const listeners = { "event": [], "disconnect": null, "error": null, "connected": null };
7
-
8
- class SocketIo {
9
-
10
- public static setIoServer(app, ioSocketConfig) {
11
- const httpServer = createServer(app);
12
- io = new IoServer(httpServer, ioSocketConfig);
13
- io.use(async (socket, next) => {
14
- if (listeners["connected"] !== null) {
15
- await getComponent(listeners["connected"].target.constructor)[listeners["connected"].propertyKey](socket, async (err) => {
16
- if (listeners["error"] !== null && err) {
17
- await getComponent(listeners["error"].target.constructor)[listeners["error"].propertyKey](socket, err);
18
- }
19
- });
20
- }
21
- next();
22
- });
23
- io.on("connection", async (socket) => {
24
- if (listeners["disconnect"] !== null) {
25
- socket.on("disconnect", async (reason) => {
26
- await getComponent(listeners["disconnect"].target.constructor)[listeners["disconnect"].propertyKey](socket, reason);
27
- });
28
- }
29
- socket.use(async ([event, ...args], next) => {
30
- try {
31
- for (let listener of listeners["event"]) {
32
- if (listener[1] === event) {
33
- await getComponent(listener[0].target.constructor)[listener[0].propertyKey](socket, ...args);
34
- }
35
- }
36
- } catch (err) {
37
- next(err);
38
- }
39
- });
40
-
41
- if (listeners["error"] !== null) {
42
- socket.on("error", async (err) => {
43
- await getComponent(listeners["error"].target.constructor)[listeners["error"].propertyKey](socket, err);
44
- });
45
- }
46
- });
47
- return httpServer;
48
- }
49
-
50
- public static onEvent(event: string) {
51
- return (target: any, propertyKey: string) => {
52
- listeners["event"].push([{
53
- target: target,
54
- propertyKey: propertyKey
55
- }, event]);
56
- }
57
- }
58
-
59
- public static onError(target: any, propertyKey: string) {
60
- listeners["error"] = {
61
- target: target,
62
- propertyKey: propertyKey
63
- };
64
- }
65
-
66
- public static onDisconnect(target: any, propertyKey: string) {
67
- listeners["disconnect"] = {
68
- target: target,
69
- propertyKey: propertyKey
70
- };
71
- }
72
-
73
- public static onConnected(target: any, propertyKey: string) {
74
- listeners["connected"] = {
75
- target: target,
76
- propertyKey: propertyKey
77
- };
78
- }
79
- }
80
-
81
- export { SocketIo, io }
@@ -1,9 +0,0 @@
1
- import * as express from 'express';
2
- export default abstract class AuthenticationFactory {
3
- public preHandle(req: express.Request, res: express.Response, next: express.NextFunction): void{
4
- next();
5
- }
6
- public afterCompletion(req: express.Request, res: express.Response, next: express.NextFunction): void{
7
- next();
8
- }
9
- }
@@ -1,7 +0,0 @@
1
- export default abstract class CacheFactory {
2
- public abstract get(key: string): any;
3
- public abstract set(key: string, value: any, expire?: number): void;
4
- public abstract del(key: string): void;
5
- public abstract has(key: string): boolean;
6
- public abstract flush(): void;
7
- }
@@ -1,4 +0,0 @@
1
- export default abstract class DataSourceFactory {
2
- public abstract readConnection();
3
- public abstract writeConnection();
4
- }
@@ -1,8 +0,0 @@
1
- export default abstract class LogFactory {
2
- public log(message?: any, ...optionalParams: any[]) : void {
3
- console.log(message, ...optionalParams);
4
- }
5
- public error(message?: any, ...optionalParams: any[]) : void {
6
- console.error(message, ...optionalParams);
7
- }
8
- }
@@ -1,6 +0,0 @@
1
- export default abstract class ServerFactory {
2
- public app;
3
- protected middlewareList: Array<any> = [];
4
- public abstract setMiddleware(middleware: any);
5
- public abstract start(port: number): any;
6
- }
@@ -1,175 +0,0 @@
1
- import * as express from "express";
2
- import * as multiparty from "multiparty";
3
- import { expressjwt } from "express-jwt";
4
- import { getComponent } from "./core.decorator";
5
-
6
- const routerMapper = {
7
- "get": {},
8
- "post": {},
9
- "all": {}
10
- };
11
- const routerParams = {};
12
- const routerParamsTotal = {};
13
- const routerMiddleware = {};
14
- function setRouter(app: express.Application) {
15
- ["get", "post", "all"].forEach(method => {
16
- for (let key in routerMapper[method]) {
17
- const rounterFunction = routerMapper[method][key];
18
- if (routerMiddleware[rounterFunction["name"]]) {
19
- const args: Array<any> = [key, ...routerMiddleware[rounterFunction["name"]], rounterFunction["invoker"]];
20
- app[method].apply(app, args);
21
- } else {
22
- app[method](key, rounterFunction["invoker"]);
23
- }
24
- }
25
- });
26
- }
27
-
28
- function mapperFunction(method: string, value: string) {
29
- return (target: any, propertyKey: string) => {
30
- routerMapper[method][value] = {
31
- "path": value,
32
- "name": [target.constructor.name, propertyKey].toString(),
33
- "target": target.constructor,
34
- "propertyKey": propertyKey,
35
- "invoker": async (req, res, next) => {
36
- const routerBean = getComponent(target.constructor);
37
- try {
38
- let paramTotal = routerBean[propertyKey].length;
39
- if(routerParamsTotal[[target.constructor.name, propertyKey].toString()]){
40
- paramTotal = Math.max(paramTotal, routerParamsTotal[[target.constructor.name, propertyKey].toString()]);
41
- }
42
- const args = [req, res, next];
43
- if(paramTotal > 0) {
44
- for(let i = 0; i < paramTotal; i++) {
45
- if(routerParams[[target.constructor.name, propertyKey, i].toString()]){
46
- args[i] = routerParams[[target.constructor.name, propertyKey, i].toString()](req, res, next);
47
- }
48
- }
49
- }
50
- const testResult = await routerBean[propertyKey].apply(routerBean, args);
51
- if (typeof testResult === "object") {
52
- res.json(testResult);
53
- } else if (typeof testResult !== "undefined") {
54
- res.send(testResult);
55
- }
56
- return testResult;
57
- } catch (err) {
58
- next(err)
59
- }
60
- }
61
- }
62
- }
63
- }
64
-
65
- function upload(target: any, propertyKey: string) {
66
- const key = [target.constructor.name, propertyKey].toString();
67
- if (routerMiddleware[key]) {
68
- routerMiddleware[key].push(uploadMiddleware);
69
- } else {
70
- routerMiddleware[key] = [uploadMiddleware];
71
- }
72
- }
73
-
74
- function uploadMiddleware(req, res, next) {
75
- const form = new multiparty.Form();
76
- form.parse(req, (err, fields, files) => {
77
- req.files = files || undefined;
78
- next();
79
- });
80
- }
81
-
82
- function jwt(jwtConfig) {
83
- return (target: any, propertyKey: string) => {
84
- const key = [target.constructor.name, propertyKey].toString();
85
- if (routerMiddleware[key]) {
86
- routerMiddleware[key].push(expressjwt(jwtConfig));
87
- } else {
88
- routerMiddleware[key] = [expressjwt(jwtConfig)];
89
- }
90
- }
91
- }
92
-
93
- function before(constructorFunction, methodName: string) {
94
- const targetBean = getComponent(constructorFunction);
95
- return function (target, propertyKey: string) {
96
- const currentMethod = targetBean[methodName];
97
- if(currentMethod.length > 0){
98
- routerParamsTotal[[constructorFunction.name, methodName].toString()] = currentMethod.length;
99
- }
100
- Object.assign(targetBean, {
101
- [methodName]: function (...args) {
102
- target[propertyKey](...args);
103
- return currentMethod.apply(targetBean, args);
104
- }
105
- })
106
- };
107
- }
108
-
109
- function after(constructorFunction, methodName: string) {
110
- const targetBean = getComponent(constructorFunction);
111
- return function (target, propertyKey: string) {
112
- const currentMethod = targetBean[methodName];
113
- if(currentMethod.length > 0){
114
- routerParamsTotal[[constructorFunction.name, methodName].toString()] = currentMethod.length;
115
- }
116
- Object.assign(targetBean, {
117
- [methodName]: function (...args) {
118
- const result = currentMethod.apply(targetBean, args);
119
- const afterResult = target[propertyKey](result);
120
- return afterResult ?? result;
121
- }
122
- })
123
- };
124
- }
125
-
126
- function req(target: any, propertyKey: string, parameterIndex: number) {
127
- const key = [target.constructor.name, propertyKey, parameterIndex].toString();
128
- routerParams[key] = (req, res, next) => req;
129
- }
130
-
131
- function res(target: any, propertyKey: string, parameterIndex: number) {
132
- const key = [target.constructor.name, propertyKey, parameterIndex].toString();
133
- routerParams[key] = (req, res, next) => res;
134
- }
135
-
136
- function next(target: any, propertyKey: string, parameterIndex: number) {
137
- const key = [target.constructor.name, propertyKey, parameterIndex].toString();
138
- routerParams[key] = (req, res, next) => next;
139
- }
140
-
141
- function reqBody(target: any, propertyKey: string, parameterIndex: number) {
142
- const key = [target.constructor.name, propertyKey, parameterIndex].toString();
143
- routerParams[key] = (req, res, next) => req.body;
144
- }
145
-
146
- function reqParam(target: any, propertyKey: string, parameterIndex: number) {
147
- const key = [target.constructor.name, propertyKey, parameterIndex].toString();
148
- const paramName = getParamInFunction(target[propertyKey], parameterIndex);
149
- routerParams[key] = (req, res, next) => req.params[paramName];
150
- }
151
-
152
- function getParamInFunction(fn: Function, index: number) {
153
- const code = fn.toString().replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg, '').replace(/=>.*$/mg, '').replace(/=[^,]+/mg, '');
154
- const result = code.slice(code.indexOf('(') + 1, code.indexOf(')')).match(/([^\s,]+)/g);
155
- return result[index] || null;
156
- }
157
-
158
- function reqQuery(target: any, propertyKey: string, parameterIndex: number) {
159
- const key = [target.constructor.name, propertyKey, parameterIndex].toString();
160
- const paramName = getParamInFunction(target[propertyKey], parameterIndex);
161
- routerParams[key] = (req, res, next) => req.query[paramName];
162
- }
163
-
164
- function reqForm(paramName: string) {
165
- return (target: any, propertyKey: string, parameterIndex: number) => {
166
- const key = [target.constructor.name, propertyKey, parameterIndex].toString();
167
- routerParams[key] = (req, res, next) => req.body[paramName];
168
- }
169
- }
170
-
171
- const getMapping = (value: string) => mapperFunction("get", value);
172
- const postMapping = (value: string) => mapperFunction("post", value);
173
- const requestMapping = (value: string) => mapperFunction("all", value);
174
-
175
- export { next, reqBody, reqQuery, reqForm, reqParam, req, req as request, res, res as response, before, after, getMapping, postMapping, requestMapping, setRouter, upload, jwt };
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from 'commander';
3
- const program = new Command();
4
- import * as fs from "fs";
5
-
6
- program.command('new [appName]')
7
- .description('Create a new app.')
8
- .action((appName) => {
9
- const currentDir = process.cwd();
10
-
11
- fs.mkdirSync(currentDir + "/" + appName);
12
- mkFile("nodemon.json", currentDir + "/" + appName, appName);
13
- mkFile("package.json", currentDir + "/" + appName, appName);
14
- mkFile("tsconfig.json", currentDir + "/" + appName, appName);
15
-
16
- fs.mkdirSync(currentDir + "/" + appName + "/src");
17
- mkFile("main.ts", currentDir + "/" + appName + "/src", appName);
18
- mkFile("front-page.class.ts", currentDir + "/" + appName + "/src", appName);
19
-
20
- console.log('');
21
- console.log(' Create app success!');
22
- console.log('');
23
- console.log(' Please run `npm install` in the app directory.');
24
- console.log('');
25
- });
26
-
27
- program.on('--help', () => {
28
- console.log('');
29
- console.log(' Examples:');
30
- console.log('');
31
- console.log(' $ typespeed new blog');
32
- });
33
-
34
- program.parse(process.argv);
35
-
36
- function mkFile(fileName, targetPath, appName) {
37
- const tplPath = __dirname + "/templates";
38
- const fileContents = fs.readFileSync(tplPath + "/" + fileName + ".tpl", "utf-8");
39
- fs.writeFileSync(targetPath + "/" + fileName, fileContents.replace("###appName###", appName));
40
- }
@@ -1,12 +0,0 @@
1
- import { log, component, getMapping } from "typespeed";
2
-
3
- @component
4
- export default class FrontPage {
5
-
6
- @getMapping("/")
7
- public index(req, res) {
8
- log("Front page running.");
9
- res.send("Front page running.");
10
- }
11
-
12
- }
@@ -1,13 +0,0 @@
1
- import { app, log, autoware, ServerFactory } from "typespeed";
2
-
3
- @app
4
- class Main {
5
-
6
- @autoware
7
- public server: ServerFactory;
8
-
9
- public main() {
10
- this.server.start(8081);
11
- log('start application');
12
- }
13
- }
@@ -1,7 +0,0 @@
1
- {
2
- "watch": [
3
- "src"
4
- ],
5
- "ext": "ts,json",
6
- "exec": "npm run test"
7
- }
@@ -1,16 +0,0 @@
1
- {
2
- "name": "###appName###",
3
- "version": "1.0.0",
4
- "scripts": {
5
- "watch": "nodemon",
6
- "test": "ts-node src/main.ts",
7
- "start": "ts-node --transpile-only src/main.ts",
8
- "build": "tsc -p ."
9
- },
10
- "dependencies": {
11
- "typespeed": "latest"
12
- },
13
- "devDependencies": {
14
- "@types/node": "^18.0.6"
15
- }
16
- }
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "CommonJS",
4
- "declaration": true,
5
- "emitDecoratorMetadata": true,
6
- "experimentalDecorators": true,
7
- "target": "ES6",
8
- "outDir": "./dist",
9
- "baseUrl": "./",
10
- "typeRoots": [
11
- "node_modules/@types"
12
- ]
13
- },
14
- "include": [
15
- "./src/**.ts"
16
- ]
17
- }