Skip to content

EMILO9/requestify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Requestify

NPM Version TypeScript NPM License

npm i @emilo/requestify
import { MongoClient } from "mongodb";
import { Requestify } from "@emilo/requestify";

(async () => {
	const isDev = process.env.NODE_ENV !== "production";
	const mongodb = new MongoClient("_fake_mongo_url_");
	await mongodb.connect();
	const db = mongodb.db("my-db");
	const app = Requestify({
		data: { db, b: 1 },
		global_middleware: [
			async ({ req, res, data, params, errorHandler }) => {},
			...(isDev ? [() => true] : []),
		],
		routes: [
			{
				path: "/",
				method: "GET",
				handler: ({ req, res, data, params, errorHandler }) => {},
				middleware: [],
			},
		],
		error_handler: async ({ req, res, data, error }) => {},
		not_found_handler: async ({ req, res, data, errorHandler }) => {},
	});
	return app;
})()
	.then((app) => app.listen(3000))
	.catch((error) => {
		console.error("Failed to start application:", error);
		process.exit(1);
	});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published