🏗 Added a scaffold for the settings service
This commit is contained in:
22
models/settings.model.ts
Normal file
22
models/settings.model.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
const mongoose = require("mongoose");
|
||||
const paginate = require("mongoose-paginate-v2");
|
||||
|
||||
const SettingsScehma = mongoose.Schema({
|
||||
directConnect: {
|
||||
client: {
|
||||
name: String,
|
||||
version: String,
|
||||
hostname: String,
|
||||
port: Number,
|
||||
https: Boolean,
|
||||
username: String,
|
||||
password: String,
|
||||
hubs: [{
|
||||
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const Settings = mongoose.model("Settings", SettingsScehma);
|
||||
export default Settings;
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
import {scrapeIssuesFromDOM} from "../utils/scraping.utils";
|
||||
const ObjectId = require("mongoose").Types.ObjectId;
|
||||
|
||||
console.log("HEYOOOOO", process.env.COMICVINE_API_KEY);
|
||||
export default class ImportService extends Service {
|
||||
public constructor(
|
||||
public broker: ServiceBroker,
|
||||
|
||||
52
services/settings.service.ts
Normal file
52
services/settings.service.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
import {
|
||||
Context,
|
||||
Service,
|
||||
ServiceBroker,
|
||||
ServiceSchema,
|
||||
Errors,
|
||||
} from "moleculer";
|
||||
import { DbMixin } from "../mixins/db.mixin";
|
||||
import Settings from "../models/settings.model";
|
||||
|
||||
export default class SettingsService extends Service {
|
||||
// @ts-ignore
|
||||
public constructor(
|
||||
public broker: ServiceBroker,
|
||||
schema: ServiceSchema<{}> = { name: "settings" }
|
||||
) {
|
||||
super(broker);
|
||||
this.parseServiceSchema(
|
||||
Service.mergeSchemas(
|
||||
{
|
||||
name: "settings",
|
||||
mixins: [DbMixin("settings", Settings)],
|
||||
settings: {
|
||||
|
||||
},
|
||||
hooks: {},
|
||||
actions: {
|
||||
getSettings: {
|
||||
rest: "GET /getAllSettings",
|
||||
params: {},
|
||||
async handler(ctx: Context<{}>) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
saveSettings: {
|
||||
rest: "POST /saveSettings",
|
||||
params: {},
|
||||
async handler(ctx: Context<{}>) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
methods: {},
|
||||
},
|
||||
schema
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user