Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 966990a

Browse files
author
Matthias Alif
committed
All unit tests passing
1 parent 640617a commit 966990a

70 files changed

Lines changed: 1276 additions & 334 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dist/ApiDocTmp/-docs-params.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

dist/App.d.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/// <reference types="node" />
2+
import Koa from "koa";
3+
export default class App {
4+
/**
5+
* @ignore
6+
*/
7+
routeParam: any;
8+
/**
9+
* @ignore
10+
*/
11+
routes: {};
12+
port: number;
13+
koaApp: Koa;
14+
constructor(opt: any);
15+
/**
16+
* @ignore
17+
*/
18+
_getAllRoutes(path: any, prefix: any): any[];
19+
/**
20+
* @access public
21+
* @desc adds the provided functions to the list of Koa middlewares to be executed for all routes.
22+
* @param {function} middlewares an array of Koa-compliant middlewares
23+
* @return { }
24+
*/
25+
addMiddlewares(middlewares: any): void;
26+
/**
27+
* @access public
28+
* @desc adds the provided function to the list of Koa middlewares to be executed for all routes.
29+
* @param {function[]} middleware an array of middlewares
30+
* @return { }
31+
*/
32+
addMiddleware(middleware: any): void;
33+
/**
34+
* @access public
35+
* @desc "mounts" a folder, scanning it for route files, then adding the discovered routes to the app.
36+
* a route is a class which extends {@link Route}
37+
* @param {string} pathFolder the path of the folder to mount
38+
* @param {string} [prefix='/'] an optional prefix to prepend to all of the folder's routes
39+
* @return { }
40+
*/
41+
mountFolder(pathFolder: any, prefix?: string, opt?: any): void;
42+
/**
43+
* @access public
44+
* @desc Launches the app and starts listening on the configured port.
45+
* @return {Koa}
46+
*/
47+
start(): Promise<import("http").Server>;
48+
}

dist/index.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import Route from './routes/Route';
2+
import App from './App';
3+
import ErrorApp from './utils/ErrorApp';
4+
import * as middlewares from './middlewares/index';
5+
declare const _default: {
6+
TypeAny: typeof import("./types/TypeAny").TypeAny;
7+
TypeArray: typeof import("./types/TypeArray").TypeArray;
8+
TypeBinary: typeof import("./types/TypeBinary").TypeBinary;
9+
TypeBoolean: typeof import("./types/TypeBoolean").TypeBoolean;
10+
TypeDate: typeof import("./types/TypeDate").TypeDate;
11+
TypeEnum: typeof import("./types/TypeEnum").TypeEnum;
12+
TypeNumber: typeof import("./types/TypeNumber").TypeNumber;
13+
TypeObject: typeof import("./types/TypeObject").TypeObject;
14+
TypeOneOf: typeof import("./types/TypeOneOf").TypeOneOf;
15+
TypeString: typeof import("./types/TypeString").TypeString;
16+
Types: {
17+
init: ({ i18n }?: {
18+
i18n?: {};
19+
}) => void;
20+
any: () => import("./types/TypeAny").TypeAny;
21+
array: () => import("./types/TypeArray").TypeArray;
22+
binary: () => import("./types/TypeBinary").TypeBinary;
23+
boolean: () => import("./types/TypeBoolean").TypeBoolean;
24+
date: () => import("./types/TypeDate").TypeDate;
25+
enum: () => import("./types/TypeEnum").TypeEnum;
26+
number: () => import("./types/TypeNumber").TypeNumber;
27+
object: () => import("./types/TypeObject").TypeObject;
28+
oneOf: () => import("./types/TypeOneOf").TypeOneOf;
29+
string: () => import("./types/TypeString").TypeString;
30+
};
31+
App: typeof App;
32+
Route: typeof Route;
33+
ErrorApp: typeof ErrorApp;
34+
StatusCode: import("./utils/StatusCode").StatusCode;
35+
middlewares: typeof middlewares;
36+
};
37+
export = _default;

dist/index.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare function addDefaultBody(ctx: any, next: any): Promise<void>;
2+
declare const _default: (body?: {}) => typeof addDefaultBody;
3+
/**
4+
* @desc middleware setting a default starting body
5+
* @param {Object} body The default body to persist through the app
6+
* @return {KoaMiddleware}
7+
*/
8+
export default _default;

dist/middlewares/handleError.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
declare function handleError(ctx: any, next: any): Promise<void>;
2+
declare const _default: (opt?: {}) => typeof handleError;
3+
/**
4+
* middleware in charge of handling errors thrown on purpose,
5+
* either through manually throwing {@link ErrorApp},
6+
* either through calling {@link Route.throw}.
7+
*
8+
* It will also make sure errors pertaining to models as well as unexpected error are given a clearer message.
9+
* @param {OptionErrors} [opt = {}] option object to set which events should be logged
10+
*/
11+
export default _default;

dist/middlewares/index.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import kbodyParser from 'koa-body';
2+
import kcors from 'kcors';
3+
export { RateLimit, Stores as RateLimitStores } from 'koa2-ratelimit';
4+
export { default as addDefaultBody } from './addDefaultBody';
5+
export { default as handleError } from './handleError';
6+
export { default as logger } from './logger';
7+
export declare const compress: any;
8+
export declare const helmet: any;
9+
export declare const bodyParser: typeof kbodyParser;
10+
export declare const cors: typeof kcors;
11+
export declare const i18n: any;

dist/middlewares/index.js

Lines changed: 14 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/middlewares/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)