Compare commits

...

20 Commits

Author SHA1 Message Date
dd91691064 3.0.25 2024-02-29 18:58:10 +01:00
bf4794c06f fix(core): update 2024-02-29 18:58:09 +01:00
7e04474a66 3.0.24 2024-02-24 18:33:33 +01:00
907d51a842 fix(core): update 2024-02-24 18:33:33 +01:00
2114ff28c0 3.0.23 2024-02-21 01:16:39 +01:00
fd9431f82b fix(core): update 2024-02-21 01:16:39 +01:00
e8c1a66e15 3.0.22 2024-02-21 01:06:53 +01:00
1e98fd99f4 fix(core): update 2024-02-21 01:06:52 +01:00
da6aa9827c 3.0.21 2024-02-20 17:30:47 +01:00
ca3b8a4580 fix(core): update 2024-02-20 17:30:46 +01:00
a7ddb6b6a8 3.0.20 2024-01-19 20:52:00 +01:00
e1dfe30273 fix(core): update 2024-01-19 20:51:59 +01:00
754fa38fe8 3.0.19 2024-01-09 11:38:52 +01:00
7e59146e73 fix(core): update 2024-01-09 11:38:51 +01:00
3b550eacf7 3.0.18 2024-01-09 11:38:19 +01:00
6342895320 fix(core): update 2024-01-09 11:38:18 +01:00
b6a4095a53 3.0.17 2024-01-09 11:38:06 +01:00
622da78180 fix(core): update 2024-01-09 11:38:06 +01:00
21938e5f20 3.0.16 2024-01-09 10:25:04 +01:00
99427f5835 fix(core): update 2024-01-09 10:25:03 +01:00
20 changed files with 424 additions and 403 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@api.global/typedserver",
"version": "3.0.15",
"version": "3.0.25",
"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.8",
"@api.global/typedrequest-interfaces": "^3.0.17",
"@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.11",
"@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": [

730
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedserver',
version: '3.0.15',
version: '3.0.25',
description: 'easy serving of static files'
}

View File

@ -1,4 +1,4 @@
import * as plugins from './typedserver.plugins.js';
import * as plugins from './plugins.js';
import * as servertools from './servertools/index.js';

View File

@ -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,

View File

@ -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 {

View File

@ -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;

View File

@ -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 {

View File

@ -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';

View File

@ -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);

View File

@ -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();
});
}
}

View File

@ -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';

View File

@ -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

View File

@ -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 {

View File

@ -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,

View File

@ -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';

View File

@ -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';

View File

@ -1,4 +1,4 @@
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';
@ -178,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();

View File

@ -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),

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@api.global/typedserver',
version: '3.0.15',
version: '3.0.25',
description: 'easy serving of static files'
}