Skip to content

Instantly share code, notes, and snippets.


Dave Carlson davecarlson

View GitHub Profile
davecarlson / apirouter.ts
Last active May 11, 2023 09:22
Middleware Wrapper Function for Next.js Pages API Routes
View apirouter.ts
/* Current Pages Directory Implementation */
// pages/api/test.ts
import { NextApiHandler, NextApiRequest, NextApiResponse } from "next";
interface RequestWithDb extends NextApiRequest {
db: string;
const withDatabase =
(fn) => async (req: NextApiRequestWithDb, res: NextApiResponse, next: NextApiHandler) => {
req.db = "database"
return fn(req, res, next);
View gist:a44162a12850378e997d
The combiner takes a comma-separated list of files:
eg: /jsc/reset.css,main.css
To use it, add this to your Apache Config:
RewriteRule ^/jsc/(.*\.js) /path/to/$1
RewriteRule ^/cssc/(.*\.css) /path/to/$1
And save the included php file to a suitable location. Your cache directory will need to be writable by the web server.
davecarlson / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console