Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
64d4fb011d | |||
6671bbe793 | |||
14bfa3f62f | |||
9e4413c276 | |||
dd91691064 | |||
bf4794c06f | |||
7e04474a66 | |||
907d51a842 | |||
2114ff28c0 | |||
fd9431f82b | |||
e8c1a66e15 | |||
1e98fd99f4 | |||
da6aa9827c | |||
ca3b8a4580 | |||
a7ddb6b6a8 | |||
e1dfe30273 | |||
754fa38fe8 | |||
7e59146e73 | |||
3b550eacf7 | |||
6342895320 | |||
b6a4095a53 | |||
622da78180 | |||
21938e5f20 | |||
99427f5835 | |||
552a15bb2f | |||
b0efc48b96 |
27
package.json
27
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@api.global/typedserver",
|
||||
"version": "3.0.14",
|
||||
"version": "3.0.27",
|
||||
"description": "easy serving of static files",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
@ -37,15 +37,16 @@
|
||||
],
|
||||
"homepage": "https://github.com/pushrocks/easyserve",
|
||||
"dependencies": {
|
||||
"@api.global/typedrequest": "^3.0.4",
|
||||
"@api.global/typedrequest-interfaces": "^3.0.1",
|
||||
"@api.global/typedrequest": "^3.0.18",
|
||||
"@api.global/typedrequest-interfaces": "^3.0.18",
|
||||
"@api.global/typedsocket": "^3.0.0",
|
||||
"@push.rocks/lik": "^6.0.12",
|
||||
"@push.rocks/smartchok": "^1.0.23",
|
||||
"@push.rocks/lik": "^6.0.14",
|
||||
"@push.rocks/smartchok": "^1.0.33",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartenv": "^5.0.12",
|
||||
"@push.rocks/smartfeed": "^1.0.11",
|
||||
"@push.rocks/smartfile": "^11.0.4",
|
||||
"@push.rocks/smartjson": "^5.0.14",
|
||||
"@push.rocks/smartlog": "^3.0.3",
|
||||
"@push.rocks/smartlog-destination-devtools": "^1.0.10",
|
||||
"@push.rocks/smartmanifest": "^2.0.2",
|
||||
@ -56,24 +57,24 @@
|
||||
"@push.rocks/smartrequest": "^2.0.21",
|
||||
"@push.rocks/smartrx": "^3.0.7",
|
||||
"@push.rocks/smartsitemap": "^2.0.3",
|
||||
"@push.rocks/smartstream": "^3.0.30",
|
||||
"@push.rocks/smartstream": "^3.0.33",
|
||||
"@push.rocks/smarttime": "^4.0.6",
|
||||
"@push.rocks/webstore": "^2.0.13",
|
||||
"@tsclass/tsclass": "^4.0.46",
|
||||
"@tsclass/tsclass": "^4.0.52",
|
||||
"@types/express": "^4.17.21",
|
||||
"body-parser": "^1.20.2",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.18.2",
|
||||
"express": "^4.18.3",
|
||||
"express-force-ssl": "^0.3.2",
|
||||
"lit": "^3.1.0"
|
||||
"lit": "^3.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.66",
|
||||
"@git.zone/tsbundle": "^2.0.8",
|
||||
"@git.zone/tsbuild": "^2.1.72",
|
||||
"@git.zone/tsbundle": "^2.0.15",
|
||||
"@git.zone/tsrun": "^1.2.44",
|
||||
"@git.zone/tstest": "^1.0.84",
|
||||
"@git.zone/tstest": "^1.0.86",
|
||||
"@push.rocks/tapbundle": "^5.0.15",
|
||||
"@types/node": "^20.10.7"
|
||||
"@types/node": "^20.11.24"
|
||||
},
|
||||
"private": false,
|
||||
"browserslist": [
|
||||
|
733
pnpm-lock.yaml
generated
733
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@api.global/typedserver',
|
||||
version: '3.0.14',
|
||||
version: '3.0.27',
|
||||
description: 'easy serving of static files'
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './typedserver.plugins.js';
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
import * as servertools from './servertools/index.js';
|
||||
|
||||
|
@ -26,6 +26,7 @@ import * as smartchok from '@push.rocks/smartchok';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartfeed from '@push.rocks/smartfeed';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartjson from '@push.rocks/smartjson';
|
||||
import * as smartmanifest from '@push.rocks/smartmanifest';
|
||||
import * as smartmime from '@push.rocks/smartmime';
|
||||
import * as smartopen from '@push.rocks/smartopen';
|
||||
@ -43,6 +44,7 @@ export {
|
||||
smartdelay,
|
||||
smartfeed,
|
||||
smartfile,
|
||||
smartjson,
|
||||
smartmanifest,
|
||||
smartmime,
|
||||
smartopen,
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
export type TCompressionMethod = 'gzip' | 'deflate' | 'br' | 'none';
|
||||
export interface ICompressionResult {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Handler } from './classes.handler.js';
|
||||
import { Server } from './classes.server.js';
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
export class Feed {
|
||||
public smartexpressRef: Server;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { type Request, type Response } from 'express';
|
||||
|
||||
export interface IHandlerFunction {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { Handler } from './classes.handler.js';
|
||||
|
||||
import * as interfaces from '../interfaces/index.js';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import * as interfaces from '../interfaces/index.js';
|
||||
|
||||
import { Handler } from './classes.handler.js';
|
||||
@ -14,7 +14,7 @@ export class HandlerStatic extends Handler {
|
||||
headers?: { [key: string]: string };
|
||||
serveIndexHtmlDefault?: boolean;
|
||||
enableCompression?: boolean;
|
||||
preferredCompressionMethod?: 'gzip' | 'deflate' | 'br';
|
||||
preferredCompressionMethod?: TCompressionMethod;
|
||||
}
|
||||
) {
|
||||
super('GET', async (req, res) => {
|
||||
@ -123,7 +123,12 @@ export class HandlerStatic extends Handler {
|
||||
let compressionResult: ICompressionResult;
|
||||
|
||||
if (optionsArg && optionsArg.enableCompression) {
|
||||
compressionResult = await this.compressor.maybeCompress(requestHeaders, fileBuffer);
|
||||
compressionResult = await this.compressor.maybeCompress(requestHeaders, fileBuffer, [optionsArg.preferredCompressionMethod]);
|
||||
} else {
|
||||
compressionResult = {
|
||||
compressionMethod: 'none',
|
||||
result: fileBuffer,
|
||||
};
|
||||
}
|
||||
|
||||
res.status(200);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { Handler } from './classes.handler.js';
|
||||
|
||||
import * as interfaces from '../interfaces/index.js';
|
||||
@ -11,7 +11,9 @@ export class HandlerTypedRouter extends Handler {
|
||||
constructor(typedrouter: plugins.typedrequest.TypedRouter) {
|
||||
super('POST', async (req, res) => {
|
||||
const response = await typedrouter.routeAndAddResponse(req.body);
|
||||
res.json(response);
|
||||
res.type('json');
|
||||
res.write(plugins.smartjson.stringify(response));
|
||||
res.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { Handler } from './classes.handler.js';
|
||||
import { Server } from './classes.server.js';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
import { Route } from './classes.route.js';
|
||||
import { Handler } from './classes.handler.js';
|
||||
@ -142,7 +142,24 @@ export class Server {
|
||||
});
|
||||
|
||||
// body parsing
|
||||
this.expressAppInstance.use(plugins.bodyParser.json({ limit: 100000000 })); // for parsing application/json
|
||||
this.expressAppInstance.use(async (req, res, next) => {
|
||||
if (req.headers['content-type'] === 'application/json') {
|
||||
let data = '';
|
||||
req.on('data', chunk => {
|
||||
data += chunk;
|
||||
});
|
||||
req.on('end', () => {
|
||||
try {
|
||||
req.body = plugins.smartjson.parse(data);
|
||||
next();
|
||||
} catch (error) {
|
||||
res.status(400).send('Invalid JSON');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
this.expressAppInstance.use(plugins.bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
||||
|
||||
// robots
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Server } from './classes.server.js';
|
||||
import { Handler } from './classes.handler.js';
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { type IUrlInfo } from '@push.rocks/smartsitemap';
|
||||
|
||||
export class Sitemap {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
export const setupManifest = async (
|
||||
expressInstanceArg: plugins.express.Application,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { Server } from './classes.server.js';
|
||||
import { Handler } from './classes.handler.js';
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from '../typedserver.plugins.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
import { Server } from './classes.server.js';
|
||||
import { Handler } from './classes.handler.js';
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
import * as plugins from './typedserver.plugins.js';
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './typedserver.paths.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
import * as servertools from './servertools/index.js';
|
||||
import { type TCompressionMethod } from './servertools/classes.compressor.js';
|
||||
|
||||
export interface IServerOptions {
|
||||
/**
|
||||
@ -14,6 +15,16 @@ export interface IServerOptions {
|
||||
*/
|
||||
injectReload?: boolean;
|
||||
|
||||
/**
|
||||
* enable compression
|
||||
*/
|
||||
enableCompression?: boolean;
|
||||
|
||||
/**
|
||||
* choose a preferred compression method
|
||||
*/
|
||||
preferredCompressionMethod?: TCompressionMethod;
|
||||
|
||||
/**
|
||||
* watch the serve directory?
|
||||
*/
|
||||
@ -157,6 +168,8 @@ export class TypedServer {
|
||||
};
|
||||
},
|
||||
serveIndexHtmlDefault: true,
|
||||
enableCompression: this.options.enableCompression,
|
||||
preferredCompressionMethod: this.options.preferredCompressionMethod,
|
||||
})
|
||||
);
|
||||
} else if (this.options.injectReload) {
|
||||
@ -165,7 +178,7 @@ export class TypedServer {
|
||||
);
|
||||
}
|
||||
if (this.options.watch && this.options.serveDir) {
|
||||
this.smartchokInstance = new plugins.smartchok.Smartchok([this.options.serveDir], {});
|
||||
this.smartchokInstance = new plugins.smartchok.Smartchok([this.options.serveDir]);
|
||||
await this.smartchokInstance.start();
|
||||
(await this.smartchokInstance.getObservableFor('change')).subscribe(async () => {
|
||||
await this.createServeDirHash();
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './typedserver.plugins.js';
|
||||
import * as plugins from './plugins.js';
|
||||
|
||||
export const packageDir = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@api.global/typedserver',
|
||||
version: '3.0.14',
|
||||
version: '3.0.27',
|
||||
description: 'easy serving of static files'
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user