Files
threetwo-core-service/services/api.service.ts
2021-09-14 23:13:34 -07:00

81 lines
1.6 KiB
TypeScript

import { Service, ServiceBroker, Context } from "moleculer";
import ApiGateway from "moleculer-web";
export default class ApiService extends Service {
public constructor(broker: ServiceBroker) {
super(broker);
// @ts-ignore
this.parseServiceSchema({
name: "api",
mixins: [ApiGateway],
// More info about settings: https://moleculer.services/docs/0.14/moleculer-web.html
settings: {
port: process.env.PORT || 3000,
routes: [
{
path: "/api",
whitelist: ["**"],
cors: {
origin: "*",
methods: [
"GET",
"OPTIONS",
"POST",
"PUT",
"DELETE",
],
allowedHeaders: ["*"],
exposedHeaders: [],
credentials: false,
maxAge: 3600,
},
use: [],
mergeParams: true,
authentication: false,
authorization: false,
autoAliases: true,
aliases: {},
callingOptions: {},
bodyParsers: {
json: {
strict: false,
limit: "1MB",
},
urlencoded: {
extended: true,
limit: "1MB",
},
},
mappingPolicy: "all", // Available values: "all", "restrict"
logging: true,
},
{
path: "/userdata",
use: [ApiGateway.serveStatic("userdata")],
},
{
path: "/comics",
use: [ApiGateway.serveStatic("comics")],
},
],
log4XXResponses: false,
logRequestParams: null,
logResponseData: null,
assets: {
folder: "public",
// Options to `server-static` module
options: {},
},
},
events: {
},
methods: {},
started(): any {
},
});
}
}