Move app class to separate module to make it easier to import for typing
This commit is contained in:
parent
52973017f4
commit
ea5d86a3c2
40
src/back/app.ts
Normal file
40
src/back/app.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import _locreq from "locreq";
|
||||||
|
import { resolve } from "path";
|
||||||
|
import { App, Collection, FieldTypes, Policies } from "sealious";
|
||||||
|
const locreq = _locreq(__dirname);
|
||||||
|
|
||||||
|
export default class TheApp extends App {
|
||||||
|
config = {
|
||||||
|
upload_path: locreq.resolve("uploaded_files"),
|
||||||
|
datastore_mongo: {
|
||||||
|
host: "localhost",
|
||||||
|
port: 20723,
|
||||||
|
db_name: "sealious-playground",
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
from_address: "sealious-playground@example.com",
|
||||||
|
from_name: "Sealious playground app",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
manifest = {
|
||||||
|
name: "Sealious Playground",
|
||||||
|
logo: resolve(__dirname, "../assets/logo.png"),
|
||||||
|
version: "0.0.1",
|
||||||
|
default_language: "en",
|
||||||
|
base_url: "localhost:8080",
|
||||||
|
admin_email: "admin@example.com",
|
||||||
|
colors: {
|
||||||
|
primary: "#5294a1",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
collections = {
|
||||||
|
...App.BaseCollections,
|
||||||
|
tasks: new (class extends Collection {
|
||||||
|
fields = {
|
||||||
|
title: new FieldTypes.Text(),
|
||||||
|
done: new FieldTypes.Boolean(),
|
||||||
|
};
|
||||||
|
defaultPolicy = new Policies.Public();
|
||||||
|
})(),
|
||||||
|
};
|
||||||
|
}
|
@ -1,14 +1,6 @@
|
|||||||
import _locreq from "locreq";
|
import _locreq from "locreq";
|
||||||
import { resolve } from "path";
|
import Sealious, { CollectionItem, Context, Middlewares } from "sealious";
|
||||||
import Sealious, {
|
import TheApp from "./app";
|
||||||
App,
|
|
||||||
Collection,
|
|
||||||
Context,
|
|
||||||
FieldTypes,
|
|
||||||
Policies,
|
|
||||||
Middlewares,
|
|
||||||
CollectionItem,
|
|
||||||
} from "sealious";
|
|
||||||
import frame from "./frame";
|
import frame from "./frame";
|
||||||
import html from "./html";
|
import html from "./html";
|
||||||
const locreq = _locreq(__dirname);
|
const locreq = _locreq(__dirname);
|
||||||
@ -16,47 +8,12 @@ const locreq = _locreq(__dirname);
|
|||||||
declare module "koa" {
|
declare module "koa" {
|
||||||
interface BaseContext {
|
interface BaseContext {
|
||||||
$context: Sealious.Context;
|
$context: Sealious.Context;
|
||||||
$app: Sealious.App;
|
$app: TheApp;
|
||||||
$body: Record<string, unknown>;
|
$body: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = new (class extends App {
|
const app = new TheApp();
|
||||||
config = {
|
|
||||||
upload_path: locreq.resolve("uploaded_files"),
|
|
||||||
datastore_mongo: {
|
|
||||||
host: "localhost",
|
|
||||||
port: 20723,
|
|
||||||
db_name: "sealious-playground",
|
|
||||||
},
|
|
||||||
email: {
|
|
||||||
from_address: "sealious-playground@example.com",
|
|
||||||
from_name: "Sealious playground app",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
manifest = {
|
|
||||||
name: "Sealious Playground",
|
|
||||||
logo: resolve(__dirname, "../assets/logo.png"),
|
|
||||||
version: "0.0.1",
|
|
||||||
default_language: "en",
|
|
||||||
base_url: "localhost:8080",
|
|
||||||
admin_email: "admin@example.com",
|
|
||||||
colors: {
|
|
||||||
primary: "#5294a1",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
collections = {
|
|
||||||
...App.BaseCollections,
|
|
||||||
tasks: new (class extends Collection {
|
|
||||||
fields = {
|
|
||||||
title: new FieldTypes.Text(),
|
|
||||||
done: new FieldTypes.Boolean(),
|
|
||||||
};
|
|
||||||
defaultPolicy = new Policies.Public();
|
|
||||||
})(),
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
app.start();
|
app.start();
|
||||||
|
|
||||||
const router = app.HTTPServer.router;
|
const router = app.HTTPServer.router;
|
||||||
|
@ -6,13 +6,11 @@
|
|||||||
"noImplicitThis": true,
|
"noImplicitThis": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"target": "ES2019",
|
"target": "ES2019",
|
||||||
"declaration": true,
|
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"lib": ["es6", "esnext"],
|
"lib": ["es6", "esnext"],
|
||||||
"outDir": "../../dist",
|
"outDir": "../../dist",
|
||||||
"checkJs": true,
|
"checkJs": true,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"declarationDir": "@types",
|
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"sourceMap": true
|
"sourceMap": true
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user