@projectinvicta/nails 3.0.5 → 3.0.7
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/index.js +9 -0
- package/lib/Nails.ts +10 -3
- package/lib/Router.ts +2 -2
- package/package.json +7 -7
- package/tests/services/integration/server/controllers/classbased_controller.js +1 -1
- package/tests/services/integration/server/controllers/default_json_controller.js +1 -1
- package/tests/services/integration/server/controllers/error_controller.js +1 -1
- package/tests/services/integration/server/controllers/home_controller.js +1 -1
- package/tests/services/integration/server/controllers/json_controller.js +1 -1
- package/tests/services/integration/server/controllers/manualrenderasync_controller.js +1 -1
- package/tests/services/integration/server/controllers/mjs_controller.mjs +1 -1
- package/tests/services/integration/server/controllers/modeltest_controller.js +2 -2
- package/tests/services/integration/server/controllers/websocket_controller.js +2 -2
- package/tests/services/integration/server/models/dog.js +1 -1
- package/tests/services/integration/server/models/owner.js +1 -1
- package/tests/services/integration/server.js +1 -1
- package/tsconfig.json +28 -0
- package/vite.config.ts +1 -0
- package/index.ts +0 -9
package/index.js
ADDED
package/lib/Nails.ts
CHANGED
|
@@ -6,11 +6,11 @@ import {type Server as HttpServer} from 'node:http';
|
|
|
6
6
|
|
|
7
7
|
import { type Application } from 'express-ws';
|
|
8
8
|
import { type InitOptions, Model, Sequelize, type ModelAttributes, type ModelStatic } from 'sequelize';
|
|
9
|
-
import expressApp from './application.
|
|
10
|
-
import Router from './Router.
|
|
9
|
+
import expressApp from './application.js';
|
|
10
|
+
import Router from './Router.js';
|
|
11
11
|
|
|
12
12
|
import { type Config } from './config.ts';
|
|
13
|
-
import Controller from './Controller.
|
|
13
|
+
import Controller from './Controller.js';
|
|
14
14
|
|
|
15
15
|
export default class Nails {
|
|
16
16
|
static Controller = Controller;
|
|
@@ -175,9 +175,13 @@ export default class Nails {
|
|
|
175
175
|
const schema = modelModule.schema;
|
|
176
176
|
const options = modelModule.options;
|
|
177
177
|
const defer = modelModule.defer as (() => Promise<void>) | undefined;
|
|
178
|
+
const afterInitialize = modelModule.afterInitialize as (() => Promise<void>) | undefined;
|
|
178
179
|
if (modelModule.finalize) {
|
|
179
180
|
this.modelFinalizations.push(modelModule.finalize as () => Promise<void>);
|
|
180
181
|
}
|
|
182
|
+
if (modelModule.afterInitializeAll) {
|
|
183
|
+
this.modelFinalizations.push(modelModule.afterInitializeAll as () => Promise<void>);
|
|
184
|
+
}
|
|
181
185
|
this.modelMigrations.push(modelModule.migrate as () => Promise<void>);
|
|
182
186
|
|
|
183
187
|
modelClass.init(schema, { sequelize: this.sequelize, ...options });
|
|
@@ -186,6 +190,9 @@ export default class Nails {
|
|
|
186
190
|
if (defer) {
|
|
187
191
|
await defer();
|
|
188
192
|
}
|
|
193
|
+
if (afterInitialize) {
|
|
194
|
+
await afterInitialize();
|
|
195
|
+
}
|
|
189
196
|
await modelClass.sync();
|
|
190
197
|
}
|
|
191
198
|
else console.warn("No model found at:", absolutePath);
|
package/lib/Router.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { EventEmitter } from 'node:events';
|
|
|
2
2
|
import {type WebSocket} from "ws";
|
|
3
3
|
import express, {type NextFunction, type Request, type Response} from 'express';
|
|
4
4
|
import expressWs, {type Router as WsRouter, type Application as WsApplication, type WebsocketRequestHandler} from 'express-ws';
|
|
5
|
-
import app, {expressRouter, ExpressRouter, expressStatic} from './application.
|
|
6
|
-
import { type RouteDefinition, type RouteOptions } from './config.
|
|
5
|
+
import app, {expressRouter, ExpressRouter, expressStatic} from './application.js';
|
|
6
|
+
import { type RouteDefinition, type RouteOptions } from './config.js';
|
|
7
7
|
|
|
8
8
|
interface ExpressWsType {
|
|
9
9
|
app: any;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectinvicta/nails",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "A node.js webserver scaffold",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "index.
|
|
6
|
+
"main": "index.js",
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=24.0.0"
|
|
9
9
|
},
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"copyreadme": "node bin/convertreadmetohtml.js",
|
|
15
15
|
"test": "vitest run ./tests",
|
|
16
16
|
"debug": "vitest --inspect-brk run ./tests",
|
|
17
|
-
"test_init": "bash bin/test/test_init.sh"
|
|
17
|
+
"test_init": "bash bin/test/test_init.sh",
|
|
18
|
+
"build": "tsc"
|
|
18
19
|
},
|
|
19
20
|
"repository": {
|
|
20
21
|
"type": "git",
|
|
@@ -49,13 +50,12 @@
|
|
|
49
50
|
"@types/express-ws": "*",
|
|
50
51
|
"@types/node": "*",
|
|
51
52
|
"chai-http": "*",
|
|
53
|
+
"typescript": "^6.0.2",
|
|
52
54
|
"vite": "^8.0.1",
|
|
53
55
|
"vitest": "^4.1.0"
|
|
54
56
|
},
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"version": "latest"
|
|
58
|
-
}
|
|
57
|
+
"imports": {
|
|
58
|
+
"#nails": "./dist/nails.js"
|
|
59
59
|
},
|
|
60
60
|
"author": "Stanton W. Jones",
|
|
61
61
|
"license": "MIT"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Controller} from "../../../../../index.
|
|
1
|
+
import {Controller} from "../../../../../index.js";
|
|
2
2
|
export default class ManualRenderAsyncController extends Controller {
|
|
3
3
|
testmanualrenderasync(params, request, response) {
|
|
4
4
|
return new Promise((resolve, reject) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {Controller} from "../../../../../index.js";
|
|
2
2
|
import Dog from "../models/dog.js";
|
|
3
3
|
|
|
4
|
-
export default class ModeltestController extends
|
|
4
|
+
export default class ModeltestController extends Controller {
|
|
5
5
|
async createdog(params, request, response) {
|
|
6
6
|
let dog = await Dog.create({good: true, name: params.name});
|
|
7
7
|
console.log("CREATED DOG ID:", dog.id);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Nails from "../../../../../index.js";
|
|
2
2
|
|
|
3
|
-
export default class WebsocketController extends
|
|
3
|
+
export default class WebsocketController extends Nails.Controller {
|
|
4
4
|
index(params, ws, request) {
|
|
5
5
|
ws.send("It worked");
|
|
6
6
|
ws.close();
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Base Options */
|
|
4
|
+
"target": "ES2022", // High target to keep modern syntax (async/await, etc.)
|
|
5
|
+
"module": "NodeNext", // Best for modern Node.js ESM/CJS compatibility
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"lib": ["ES2022"],
|
|
8
|
+
|
|
9
|
+
/* Output */
|
|
10
|
+
"outDir": "./dist", // Where the JS goes
|
|
11
|
+
"rootDir": "./lib", // Where your TS lives
|
|
12
|
+
"declaration": true, // Generates .d.ts files (essential for libraries)
|
|
13
|
+
"sourceMap": true, // Helps with debugging the original TS
|
|
14
|
+
"removeComments": false, // Keeping comments is usually better for library users
|
|
15
|
+
|
|
16
|
+
/* Strictness & Safety */
|
|
17
|
+
"strict": true, // Recommended to ensure your types are actually valid
|
|
18
|
+
"esModuleInterop": true, // Ensures compatibility with older packages
|
|
19
|
+
"skipLibCheck": true, // Speeds up build by not checking node_modules
|
|
20
|
+
"forceConsistentCasingInFileNames": true,
|
|
21
|
+
|
|
22
|
+
/* Emit Behavior */
|
|
23
|
+
"emitDeclarationOnly": false, // We want both JS and type definitions
|
|
24
|
+
"isolatedModules": true // Ensures each file can be safely transpiled independently
|
|
25
|
+
},
|
|
26
|
+
"include": ["lib/*"],
|
|
27
|
+
"exclude": ["node_modules", "**/*.test.ts"]
|
|
28
|
+
}
|
package/vite.config.ts
CHANGED
package/index.ts
DELETED