prepare npm publish

This commit is contained in:
Flam3rboy
2021-04-22 23:29:06 +02:00
parent 9705b01fdc
commit 4528a96ded
12 changed files with 104 additions and 61 deletions
+5 -5
View File
@@ -13,21 +13,21 @@ import { BodyParser } from "./middlewares/BodyParser";
import { Router } from "express";
import fetch from "node-fetch";
export interface DiscordServerOptions extends ServerOptions {}
export interface FosscordServerOptions extends ServerOptions {}
declare global {
namespace Express {
interface Request {
// @ts-ignore
server: DiscordServer;
server: FosscordServer;
}
}
}
export class DiscordServer extends Server {
public options: DiscordServerOptions;
export class FosscordServer extends Server {
public options: FosscordServerOptions;
constructor(opts?: Partial<DiscordServerOptions>) {
constructor(opts?: Partial<FosscordServerOptions>) {
// @ts-ignore
super({ ...opts, errorHandler: false, jsonBody: false });
}
+19 -33
View File
@@ -1,33 +1,19 @@
process.on("uncaughtException", console.error);
process.on("unhandledRejection", console.error);
import "missing-native-js-functions";
import { config } from "dotenv";
config();
import { DiscordServer } from "./Server";
import cluster from "cluster";
import os from "os";
const cores = os.cpus().length;
if (cluster.isMaster && process.env.production == "true") {
console.log(`Primary ${process.pid} is running`);
// Fork workers.
for (let i = 0; i < cores; i++) {
cluster.fork();
}
cluster.on("exit", (worker, code, signal) => {
console.log(`worker ${worker.process.pid} died, restart worker`);
cluster.fork();
});
} else {
var port = Number(process.env.PORT);
if (isNaN(port)) port = 1000;
const server = new DiscordServer({ port });
server.start().catch(console.error);
// @ts-ignore
global.server = server;
}
export * from "./Server";
export * from "./middlewares/";
export * from "./schema/Ban";
export * from "./schema/Channel";
export * from "./schema/Guild";
export * from "./schema/Invite";
export * from "./schema/Message";
export * from "./util/Captcha";
export * from "./util/Config";
export * from "./util/Constants";
export * from "./util/Event";
export * from "./util/instanceOf";
export * from "./util/Event";
export * from "./util/instanceOf";
export * from "./util/Member";
export * from "./util/RandomInviteID";
export * from "./util/String";
export * from "./util/User";
export { check as checkPassword } from "./util/passwordStrength";
+6 -4
View File
@@ -1,4 +1,6 @@
import { Authentication } from "./Authentication";
import { GlobalRateLimit } from "./GlobalRateLimit";
export { Authentication, GlobalRateLimit };
export * from "./GlobalRateLimit";
export * from "./Authentication";
export * from "./BodyParser";
export * from "./CORS";
export * from "./ErrorHandler";
export * from "./RateLimit";
+33
View File
@@ -0,0 +1,33 @@
process.on("uncaughtException", console.error);
process.on("unhandledRejection", console.error);
import "missing-native-js-functions";
import { config } from "dotenv";
config();
import { FosscordServer } from "./Server";
import cluster from "cluster";
import os from "os";
const cores = os.cpus().length;
if (cluster.isMaster && process.env.production == "true") {
console.log(`Primary ${process.pid} is running`);
// Fork workers.
for (let i = 0; i < cores; i++) {
cluster.fork();
}
cluster.on("exit", (worker, code, signal) => {
console.log(`worker ${worker.process.pid} died, restart worker`);
cluster.fork();
});
} else {
var port = Number(process.env.PORT);
if (isNaN(port)) port = 1000;
const server = new FosscordServer({ port });
server.start().catch(console.error);
// @ts-ignore
global.server = server;
}
+1
View File
@@ -0,0 +1 @@
export {};
+3 -3
View File
@@ -16,7 +16,7 @@ export default {
setAll: Config.setAll,
};
export interface RateLimit {
export interface RateLimitOptions {
count: number;
timespan: number;
}
@@ -62,8 +62,8 @@ export interface DefaultOptions {
};
routes: {
auth?: {
login?: RateLimit;
register?: RateLimit;
login?: RateLimitOptions;
register?: RateLimitOptions;
};
channel?: {};
// TODO: rate limit configuration for all routes