@maroonedsoftware/koa 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +119 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware/router/body.parser.middleware.d.ts +3 -0
- package/dist/middleware/router/body.parser.middleware.d.ts.map +1 -0
- package/dist/middleware/server/error.middleware.d.ts +3 -0
- package/dist/middleware/server/error.middleware.d.ts.map +1 -0
- package/dist/middleware/server/injectkit.middleware.d.ts +4 -0
- package/dist/middleware/server/injectkit.middleware.d.ts.map +1 -0
- package/dist/serverkit.context.d.ts +8 -0
- package/dist/serverkit.context.d.ts.map +1 -0
- package/dist/serverkit.middleware.d.ts +4 -0
- package/dist/serverkit.middleware.d.ts.map +1 -0
- package/dist/serverkit.router.d.ts +5 -0
- package/dist/serverkit.router.d.ts.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Marooned Software
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @maroonedsoftware/logger
|
|
2
|
+
|
|
3
|
+
A simple, dependency injection friendly logging abstraction with multiple log levels.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @maroonedsoftware/logger
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Basic Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { ConsoleLogger } from '@maroonedsoftware/logger';
|
|
17
|
+
|
|
18
|
+
const logger = new ConsoleLogger();
|
|
19
|
+
|
|
20
|
+
logger.error('Something went wrong', { details: 'error context' });
|
|
21
|
+
logger.warn('This might be a problem');
|
|
22
|
+
logger.info('Application started');
|
|
23
|
+
logger.debug('Processing request', requestData);
|
|
24
|
+
logger.trace('Entering function');
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### With Dependency Injection
|
|
28
|
+
|
|
29
|
+
The `Logger` abstract class is decorated with `@Injectable()` from [injectkit](https://www.npmjs.com/package/injectkit), making it easy to use with DI containers:
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import 'reflect-metadata';
|
|
33
|
+
import { InjectKitRegistry } from 'injectkit';
|
|
34
|
+
import { Logger, ConsoleLogger } from '@maroonedsoftware/logger';
|
|
35
|
+
|
|
36
|
+
// Set up dependency injection registry
|
|
37
|
+
const diRegistry = new InjectKitRegistry();
|
|
38
|
+
diRegistry.register(Logger).useClass(ConsoleLogger).asSingleton();
|
|
39
|
+
|
|
40
|
+
// Build the container
|
|
41
|
+
const container = diRegistry.build();
|
|
42
|
+
|
|
43
|
+
// Resolve the logger
|
|
44
|
+
const logger = container.get(Logger);
|
|
45
|
+
logger.info('Application started');
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
In your services, use constructor injection:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Injectable } from 'injectkit';
|
|
52
|
+
import { Logger } from '@maroonedsoftware/logger';
|
|
53
|
+
|
|
54
|
+
@Injectable()
|
|
55
|
+
class MyService {
|
|
56
|
+
constructor(private logger: Logger) {}
|
|
57
|
+
|
|
58
|
+
doSomething() {
|
|
59
|
+
this.logger.info('Doing something');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## API
|
|
65
|
+
|
|
66
|
+
### Logger Interface
|
|
67
|
+
|
|
68
|
+
| Method | Description |
|
|
69
|
+
| --------------------------- | ----------------------------- |
|
|
70
|
+
| `error(message, ...params)` | Logs an error message |
|
|
71
|
+
| `warn(message, ...params)` | Logs a warning message |
|
|
72
|
+
| `info(message, ...params)` | Logs an informational message |
|
|
73
|
+
| `debug(message, ...params)` | Logs a debug message |
|
|
74
|
+
| `trace(message, ...params)` | Logs a trace message |
|
|
75
|
+
|
|
76
|
+
### ConsoleLogger
|
|
77
|
+
|
|
78
|
+
A concrete implementation that outputs to the standard console. Accepts an optional `Console` instance in the constructor for custom console implementations.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// Use global console (default)
|
|
82
|
+
const logger = new ConsoleLogger();
|
|
83
|
+
|
|
84
|
+
// Use custom console
|
|
85
|
+
const customConsole = { ... };
|
|
86
|
+
const logger = new ConsoleLogger(customConsole);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './serverkit.context.js';
|
|
2
|
+
export * from './serverkit.middleware.js';
|
|
3
|
+
export * from './serverkit.router.js';
|
|
4
|
+
export * from './middleware/server/error.middleware.js';
|
|
5
|
+
export * from './middleware/server/injectkit.middleware.js';
|
|
6
|
+
export * from './middleware/router/body.parser.middleware.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/serverkit.router.ts
|
|
5
|
+
import Router from "@koa/router";
|
|
6
|
+
var ServerKitRouter = /* @__PURE__ */ __name(() => new Router(), "ServerKitRouter");
|
|
7
|
+
|
|
8
|
+
// src/middleware/server/error.middleware.ts
|
|
9
|
+
import { IsHttpError } from "@maroonedsoftware/errors";
|
|
10
|
+
var errorMiddleware = /* @__PURE__ */ __name(() => {
|
|
11
|
+
return async (ctx, next) => {
|
|
12
|
+
try {
|
|
13
|
+
await next();
|
|
14
|
+
if (ctx.status === 404 && !ctx.body) {
|
|
15
|
+
const body = {
|
|
16
|
+
statusCode: 404,
|
|
17
|
+
message: "Not Found",
|
|
18
|
+
details: {
|
|
19
|
+
url: ctx.URL.toString()
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
ctx.status = 404;
|
|
23
|
+
ctx.body = body;
|
|
24
|
+
ctx.app.emit("warn", body, ctx);
|
|
25
|
+
}
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (IsHttpError(error)) {
|
|
28
|
+
ctx.status = error.statusCode;
|
|
29
|
+
ctx.body = {
|
|
30
|
+
statusCode: error.statusCode,
|
|
31
|
+
message: error.message,
|
|
32
|
+
details: error.details
|
|
33
|
+
};
|
|
34
|
+
if (error.headers) {
|
|
35
|
+
for (const entry of Object.entries(error.headers)) {
|
|
36
|
+
ctx.set(entry[0], entry[1]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
ctx.status = 500;
|
|
41
|
+
ctx.body = {
|
|
42
|
+
statusCode: 500,
|
|
43
|
+
message: "Internal Server Error"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
ctx.app.emit("error", error, ctx);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, "errorMiddleware");
|
|
50
|
+
|
|
51
|
+
// src/middleware/server/injectkit.middleware.ts
|
|
52
|
+
import { Logger } from "@maroonedsoftware/logger";
|
|
53
|
+
var injectkitMiddleware = /* @__PURE__ */ __name((container) => {
|
|
54
|
+
return async (ctx, next) => {
|
|
55
|
+
ctx.container = container.createScopedContainer();
|
|
56
|
+
ctx.logger = container.get(Logger);
|
|
57
|
+
await next();
|
|
58
|
+
};
|
|
59
|
+
}, "injectkitMiddleware");
|
|
60
|
+
|
|
61
|
+
// src/middleware/router/body.parser.middleware.ts
|
|
62
|
+
import coBody from "co-body";
|
|
63
|
+
import { httpError, IsHttpError as IsHttpError2 } from "@maroonedsoftware/errors";
|
|
64
|
+
import { MultipartBody } from "@maroonedsoftware/multipart";
|
|
65
|
+
import rawBody from "raw-body";
|
|
66
|
+
var bodyParserMiddleware = /* @__PURE__ */ __name((contentTypes) => {
|
|
67
|
+
return async (ctx, next) => {
|
|
68
|
+
if (contentTypes.length === 0) {
|
|
69
|
+
if (ctx.request.length > 0) {
|
|
70
|
+
throw httpError(400).withErrors({
|
|
71
|
+
body: "Unexpected body"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
if (ctx.request.length > 0) {
|
|
76
|
+
if (!ctx.request.is(contentTypes)) {
|
|
77
|
+
throw httpError(415).withErrors({
|
|
78
|
+
"content-type": `must be ${contentTypes.length > 1 ? "one of " : ""}${contentTypes.join(", ")}`,
|
|
79
|
+
value: ctx.request.type
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
if (ctx.request.is("json", "application/*+json")) {
|
|
84
|
+
ctx.body = await coBody.json(ctx);
|
|
85
|
+
} else if (ctx.request.is("urlencoded")) {
|
|
86
|
+
ctx.body = await coBody.form(ctx);
|
|
87
|
+
} else if (ctx.request.is("text/*")) {
|
|
88
|
+
ctx.body = await coBody.text(ctx);
|
|
89
|
+
} else if (ctx.request.is("multipart")) {
|
|
90
|
+
ctx.body = new MultipartBody(ctx.req);
|
|
91
|
+
} else if (ctx.request.is("pdf")) {
|
|
92
|
+
ctx.body = await rawBody(ctx.req);
|
|
93
|
+
} else {
|
|
94
|
+
throw httpError(422).withErrors({
|
|
95
|
+
body: "Unsupported media type"
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (IsHttpError2(error)) {
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
throw httpError(422).withCause(error).withErrors({
|
|
103
|
+
body: "Invalid request body format"
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
throw httpError(411);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
await next();
|
|
111
|
+
};
|
|
112
|
+
}, "bodyParserMiddleware");
|
|
113
|
+
export {
|
|
114
|
+
ServerKitRouter,
|
|
115
|
+
bodyParserMiddleware,
|
|
116
|
+
errorMiddleware,
|
|
117
|
+
injectkitMiddleware
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/serverkit.router.ts","../src/middleware/server/error.middleware.ts","../src/middleware/server/injectkit.middleware.ts","../src/middleware/router/body.parser.middleware.ts"],"sourcesContent":["import { DefaultState } from 'koa';\nimport Router from '@koa/router';\nimport { ServerKitContext } from './serverkit.context.js';\n\nexport const ServerKitRouter = <StateT = DefaultState, ContextT = ServerKitContext>() => new Router<StateT, ContextT>();\n","import { ServerKitMiddleware } from '../../serverkit.middleware.js';\nimport { IsHttpError } from '@maroonedsoftware/errors';\n\nexport const errorMiddleware = (): ServerKitMiddleware => {\n return async (ctx, next) => {\n try {\n await next();\n if (ctx.status === 404 && !ctx.body) {\n const body = {\n statusCode: 404,\n message: 'Not Found',\n details: { url: ctx.URL.toString() },\n };\n ctx.status = 404;\n ctx.body = body;\n ctx.app.emit('warn', body, ctx);\n }\n } catch (error) {\n if (IsHttpError(error)) {\n ctx.status = error.statusCode;\n ctx.body = {\n statusCode: error.statusCode,\n message: error.message,\n details: error.details,\n };\n if (error.headers) {\n for (const entry of Object.entries(error.headers)) {\n ctx.set(entry[0], entry[1]);\n }\n }\n } else {\n ctx.status = 500;\n ctx.body = {\n statusCode: 500,\n message: 'Internal Server Error',\n };\n }\n\n ctx.app.emit('error', error, ctx);\n }\n };\n};\n","import { Container } from 'injectkit';\nimport { Logger } from '@maroonedsoftware/logger';\nimport { ServerKitMiddleware } from '../../serverkit.middleware.js';\n\nexport const injectkitMiddleware = (container: Container): ServerKitMiddleware => {\n return async (ctx, next) => {\n ctx.container = container.createScopedContainer();\n ctx.logger = container.get(Logger);\n await next();\n };\n};\n","import coBody from 'co-body';\nimport { httpError, IsHttpError } from '@maroonedsoftware/errors';\nimport { MultipartBody } from '@maroonedsoftware/multipart';\nimport rawBody from 'raw-body';\nimport { ServerKitMiddleware } from '../../serverkit.middleware.js';\n\nexport const bodyParserMiddleware = (contentTypes: string[]): ServerKitMiddleware => {\n return async (ctx, next) => {\n if (contentTypes.length === 0) {\n if (ctx.request.length > 0) {\n throw httpError(400).withErrors({ body: 'Unexpected body' });\n }\n } else {\n if (ctx.request.length > 0) {\n if (!ctx.request.is(contentTypes)) {\n throw httpError(415).withErrors({\n 'content-type': `must be ${contentTypes.length > 1 ? 'one of ' : ''}${contentTypes.join(', ')}`,\n value: ctx.request.type,\n });\n }\n\n try {\n if (ctx.request.is('json', 'application/*+json')) {\n ctx.body = await coBody.json(ctx);\n } else if (ctx.request.is('urlencoded')) {\n ctx.body = await coBody.form(ctx);\n } else if (ctx.request.is('text/*')) {\n ctx.body = await coBody.text(ctx);\n } else if (ctx.request.is('multipart')) {\n ctx.body = new MultipartBody(ctx.req);\n } else if (ctx.request.is('pdf')) {\n ctx.body = await rawBody(ctx.req);\n } else {\n throw httpError(422).withErrors({ body: 'Unsupported media type' });\n }\n } catch (error) {\n if (IsHttpError(error)) {\n throw error;\n }\n throw httpError(422)\n .withCause(error as Error)\n .withErrors({ body: 'Invalid request body format' });\n }\n } else {\n throw httpError(411);\n }\n }\n await next();\n };\n};\n"],"mappings":"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","names":["Router","ServerKitRouter","Router","IsHttpError","errorMiddleware","ctx","next","status","body","statusCode","message","details","url","URL","toString","app","emit","error","IsHttpError","headers","entry","Object","entries","set","Logger","injectkitMiddleware","container","ctx","next","createScopedContainer","logger","get","Logger","coBody","httpError","IsHttpError","MultipartBody","rawBody","bodyParserMiddleware","contentTypes","ctx","next","length","request","httpError","withErrors","body","is","join","value","type","coBody","json","form","text","MultipartBody","req","rawBody","error","IsHttpError","withCause"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.parser.middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/router/body.parser.middleware.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,eAAO,MAAM,oBAAoB,GAAI,cAAc,MAAM,EAAE,KAAG,mBA2C7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/server/error.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,eAAO,MAAM,eAAe,QAAO,mBAsClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectkit.middleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/server/injectkit.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,eAAO,MAAM,mBAAmB,GAAI,WAAW,SAAS,KAAG,mBAM1D,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Context } from 'koa';
|
|
2
|
+
import { Container } from 'injectkit';
|
|
3
|
+
import { Logger } from '@maroonedsoftware/logger';
|
|
4
|
+
export interface ServerKitContext extends Context {
|
|
5
|
+
container: Container;
|
|
6
|
+
logger: Logger;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=serverkit.context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverkit.context.d.ts","sourceRoot":"","sources":["../src/serverkit.context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,MAAM,WAAW,gBAAiB,SAAQ,OAAO;IAC/C,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DefaultState, Middleware } from 'koa';
|
|
2
|
+
import { ServerKitContext } from './serverkit.context.js';
|
|
3
|
+
export type ServerKitMiddleware<ResponseBody = unknown, State = DefaultState, Context extends ServerKitContext = ServerKitContext> = Middleware<State, Context, ResponseBody>;
|
|
4
|
+
//# sourceMappingURL=serverkit.middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverkit.middleware.d.ts","sourceRoot":"","sources":["../src/serverkit.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,MAAM,mBAAmB,CAAC,YAAY,GAAG,OAAO,EAAE,KAAK,GAAG,YAAY,EAAE,OAAO,SAAS,gBAAgB,GAAG,gBAAgB,IAAI,UAAU,CAC7I,KAAK,EACL,OAAO,EACP,YAAY,CACb,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DefaultState } from 'koa';
|
|
2
|
+
import Router from '@koa/router';
|
|
3
|
+
import { ServerKitContext } from './serverkit.context.js';
|
|
4
|
+
export declare const ServerKitRouter: <StateT = DefaultState, ContextT = ServerKitContext>() => Router<StateT, ContextT>;
|
|
5
|
+
//# sourceMappingURL=serverkit.router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverkit.router.d.ts","sourceRoot":"","sources":["../src/serverkit.router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,eAAO,MAAM,eAAe,GAAI,MAAM,GAAG,YAAY,EAAE,QAAQ,GAAG,gBAAgB,+BAAqC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maroonedsoftware/koa",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Marooned Software",
|
|
7
|
+
"url": "https://github.com/MaroonedSoftware/serverkit"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/MaroonedSoftware/serverkit/issues"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/MaroonedSoftware/serverkit/packages/koa#readme",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"backend",
|
|
15
|
+
"koa",
|
|
16
|
+
"serverkit",
|
|
17
|
+
"typescript"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/MaroonedSoftware/serverkit.git"
|
|
22
|
+
},
|
|
23
|
+
"private": false,
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/**"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"co-body": "^6.2.0",
|
|
34
|
+
"injectkit": "^1.0.3",
|
|
35
|
+
"raw-body": "^3.0.2",
|
|
36
|
+
"@maroonedsoftware/logger": "1.0.0",
|
|
37
|
+
"@maroonedsoftware/multipart": "1.0.0",
|
|
38
|
+
"@maroonedsoftware/errors": "1.0.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"koa": "^3.1.1",
|
|
42
|
+
"@koa/router": "^15.2.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/co-body": "^6.1.3",
|
|
46
|
+
"@types/koa": "^3.0.1",
|
|
47
|
+
"@types/koa__router": "^12.0.5",
|
|
48
|
+
"koa": "^3.1.1",
|
|
49
|
+
"@koa/router": "^15.2.0",
|
|
50
|
+
"@repo/config-eslint": "0.0.0",
|
|
51
|
+
"@repo/config-typescript": "0.0.0"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly --declaration",
|
|
55
|
+
"build:ci": "eslint --max-warnings=0 && pnpm run build",
|
|
56
|
+
"lint": "eslint --fix",
|
|
57
|
+
"format": "prettier --write .",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"test:ci": "vitest run --coverage"
|
|
60
|
+
}
|
|
61
|
+
}
|