Skip to content

Commit

Permalink
feat: bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Prozi committed Sep 5, 2024
1 parent 8e4c116 commit 7126a23
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 31 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = startChef;
const chef_core_1 = require("chef-core");
const server_1 = require("./server");
async function startChef(config) {
Expand All @@ -11,4 +12,3 @@ async function startChef(config) {
},
);
}
exports.default = startChef;
6 changes: 3 additions & 3 deletions dist/server/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Request, Response } from "express";
import { Config, FileReaderResponse, Server } from "chef-core";
import { NextFunction, Request, Response } from "express";
import { Cache } from "@pietal.dev/cache";
import { Config, Server, FileReaderResponse } from "chef-core";
export declare function createServer(config: Config): Promise<Server>;
export declare function requestHandler(
fileReaderCache: Cache<FileReaderResponse>,
): (req: Request, res: Response) => void;
): (req: Request, res: Response, next: NextFunction) => void;
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion dist/server/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions dist/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ var __importDefault =
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.requestHandler = exports.createServer = void 0;
exports.createServer = createServer;
exports.requestHandler = requestHandler;
const chef_core_1 = require("chef-core");
const socket_io_1 = require("socket.io");
const config_1 = require("chef-core/config");
const express_1 = __importDefault(require("express"));
const http_1 = __importDefault(require("http"));
const https_1 = __importDefault(require("https"));
const express_1 = __importDefault(require("express"));
const socket_io_1 = require("socket.io");
const fs_1 = require("fs");
const config_1 = require("chef-core/config");
const chef_core_1 = require("chef-core");
async function createServer(config) {
const app = (0, express_1.default)();
const server = createExpressServer(config, app);
Expand Down Expand Up @@ -68,7 +69,6 @@ async function createServer(config) {
};
return app;
}
exports.createServer = createServer;
function createExpressServer(config, app) {
// spread ssl from config
const { ssl } = config;
Expand All @@ -85,9 +85,16 @@ function createExpressServer(config, app) {
return http_1.default.createServer(app);
}
function requestHandler(fileReaderCache) {
return (req, res) => {
return (req, res, next) => {
const url = (0, chef_core_1.getUrl)(req.originalUrl);
const { status, mime, body } = fileReaderCache.get(url);
if (!url.match(new RegExp(`/${config_1.folder}/`))) {
return next();
}
const get = fileReaderCache.get(url);
if (!get) {
return next();
}
const { status, mime, body } = get;
if (config_1.debug) {
console.info(status, mime, url);
}
Expand All @@ -98,4 +105,3 @@ function requestHandler(fileReaderCache) {
res.end(body);
};
}
exports.requestHandler = requestHandler;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chef-socket",
"version": "2.2.0",
"version": "2.3.0",
"keywords": [
"chef-js",
"server",
Expand Down Expand Up @@ -40,7 +40,7 @@
"precommit": "yarn build && prettier . --write"
},
"dependencies": {
"chef-core": "^3.1.0",
"chef-core": "^3.2.0",
"express": "^4.19.2",
"socket.io": "^4.7.5"
},
Expand Down
33 changes: 22 additions & 11 deletions src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import http, { RequestListener } from "http";
import https from "https";
import express, { Request, Response } from "express";
import { Cache } from "@pietal.dev/cache";
import { Socket, Server as SocketServer } from "socket.io";
import { readFileSync } from "fs";
import { debug } from "chef-core/config";
import {
Config,
Server,
Event,
Plugin,
FileReaderResponse,
Plugin,
Server,
getPlugin,
getUrl,
} from "chef-core";
import { Socket, Server as SocketServer } from "socket.io";
import { debug, folder } from "chef-core/config";
import express, { NextFunction, Request, Response } from "express";
import http, { RequestListener } from "http";

import { Cache } from "@pietal.dev/cache";
import https from "https";
import { readFileSync } from "fs";

export async function createServer(config: Config): Promise<Server> {
const app: Express.Application = express();
Expand Down Expand Up @@ -109,9 +110,19 @@ function createExpressServer(
}

export function requestHandler(fileReaderCache: Cache<FileReaderResponse>) {
return (req: Request, res: Response) => {
return (req: Request, res: Response, next: NextFunction) => {
const url: string = getUrl(req.originalUrl);
const { status, mime, body } = fileReaderCache.get(url);
if (!url.match(new RegExp(`/${folder}/`))) {
return next();
}

const get = fileReaderCache.get(url);

if (!get) {
return next();
}

const { status, mime, body } = get;

if (debug) {
console.info(status, mime, url);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1355,10 +1355,10 @@ char-regex@^1.0.2:
resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==

chef-core@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/chef-core/-/chef-core-3.1.0.tgz#7b5c4bdaf1d9de09374c21fa4f45727732dbec1f"
integrity sha512-EsOSgfBwTuyXZtb7k3oEtfj4t8BCyxaNXiN3WIaEOceI14EZ2Z2U4yLqsOteVRjpRXJ2PFX8OJyz5SzN/WgR0Q==
chef-core@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/chef-core/-/chef-core-3.2.0.tgz#b0fb97840cadf53c5943334af9b1dcfc24d1cd75"
integrity sha512-tBV+cRC1ZqQeRcxb2yGxdXkxF+GcL9U6pc3EYAzcrA5DAq7jocOKiGEM9wBS3p5y6zVdUEADRHMvc6sfZzHZ0Q==
dependencies:
"@pietal.dev/cache" "^2.0.2"
mime-types "^2.1.35"
Expand Down

0 comments on commit 7126a23

Please sign in to comment.