View apirouter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/combine-gzip.inc.php?type=javascript&encoding=none&files=$1 | |
RewriteRule ^/cssc/(.*\.css) /path/to/combine-gzip.inc.php?type=css&encoding=none&files=$1 | |
And save the included php file to a suitable location. Your cache directory will need to be writable by the web server. |
View 0_reuse_code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |