### Navigate to Example Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/opentype.js/examples/README.md Example URL to access a specific OpenType.js example in a browser after starting the local web server. ```bash http://localhost:8080/examples/reading-writing.html ``` -------------------------------- ### Install serve-static with npm Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/serve-static/README.md Install the serve-static package using the npm install command. ```sh $ npm install serve-static ``` -------------------------------- ### Start the Express application Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/Readme.md Starts the Express application server using the npm start script. ```bash $ npm start ``` -------------------------------- ### Install universalify Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/universalify/README.md Install the universalify package using npm. ```bash npm install universalify ``` -------------------------------- ### Install on-finished Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/on-finished/README.md Install the on-finished module using npm. ```sh $ npm install on-finished ``` -------------------------------- ### Install parseurl with npm Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/parseurl/README.md Install the parseurl module using the npm install command. ```sh npm install parseurl ``` -------------------------------- ### Install encodeurl with npm Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/encodeurl/README.md Install the encodeurl module using the npm install command. ```sh npm install encodeurl ``` -------------------------------- ### Install ee-first Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/ee-first/README.md Install the ee-first module using npm. ```sh $ npm install ee-first ``` -------------------------------- ### Install Negotiator Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/negotiator/README.md Install the negotiator module using npm. ```sh npm install negotiator ``` -------------------------------- ### Install proxy-addr Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/proxy-addr/README.md Install the proxy-addr module using npm. ```sh $ npm install proxy-addr ``` -------------------------------- ### Install isarray with npm Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/isarray/README.md Install the isarray package using npm for Node.js projects. This command downloads and installs the package into your project's node_modules directory. ```bash $ npm install isarray ``` -------------------------------- ### Install Fresh Module Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/fresh/README.md Install the fresh module using npm. ```bash npm install fresh ``` -------------------------------- ### Run an Express example Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/Readme.md Executes a specific example from the cloned Express.js repository, such as 'content-negotiation'. ```bash $ node examples/content-negotiation ``` -------------------------------- ### Install Methods Module Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/methods/README.md Install the 'methods' module using npm. ```bash $ npm install methods ``` -------------------------------- ### Install Send Library Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/send/README.md Install the 'send' library using npm. ```bash $ npm install send ``` -------------------------------- ### Install media-typer Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/media-typer/README.md Install the media-typer module using npm. ```sh $ npm install media-typer ``` -------------------------------- ### Install type-is Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/type-is/README.md Install the type-is module using npm. ```sh $ npm install type-is ``` -------------------------------- ### Basic File Serving Example Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/send/README.md A minimal example demonstrating how to serve files from the request's pathname using the 'send' module. ```javascript var http = require('http') var parseUrl = require('parseurl') var send = require('send') var server = http.createServer(function onRequest (req, res) { send(req, parseUrl(req).pathname).pipe(res) }) server.listen(3000) ``` -------------------------------- ### Install raw-body Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/node_modules/raw-body/README.md Install the raw-body module using npm. ```sh npm install raw-body ``` -------------------------------- ### Install express-fileupload with Yarn Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express-fileupload/README.md Install the express-fileupload package using Yarn. ```bash yarn add express-fileupload ``` -------------------------------- ### Install safe-buffer Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/safe-buffer/README.md Install the safe-buffer package using npm. ```bash npm install safe-buffer ``` -------------------------------- ### Install text-to-svg Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/text-to-svg/README.md Installs the text-to-svg package using npm. ```bash $ npm install --save text-to-svg ``` -------------------------------- ### Install tiny-inflate Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/tiny-inflate/readme.md Install the tiny-inflate package using npm. ```bash npm install tiny-inflate ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/opentype.js/CONTRIBUTING.md Install the necessary dependencies for developing opentype.js. ```bash cd opentype.js npm install ``` -------------------------------- ### Install unpipe Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/unpipe/README.md Install the unpipe module using npm. ```sh $ npm install unpipe ``` -------------------------------- ### Install express-fileupload with NPM Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express-fileupload/README.md Install the express-fileupload package using npm. ```bash npm install --save express-fileupload ``` -------------------------------- ### Install range-parser Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/range-parser/README.md Install the range-parser module using npm. ```bash $ npm install range-parser ``` -------------------------------- ### Install content-type Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/content-type/README.md Install the content-type module using npm. ```sh $ npm install content-type ``` -------------------------------- ### Install is-buffer Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/is-buffer/README.md Install the is-buffer package using npm. ```bash npm install is-buffer ``` -------------------------------- ### Install body-parser Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/body-parser/README.md Install the body-parser middleware using npm. ```sh $ npm install body-parser ``` -------------------------------- ### Install setprototypeof Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/node_modules/raw-body/node_modules/setprototypeof/README.md Install the `setprototypeof` package using npm. ```bash $ npm install --save setprototypeof ``` -------------------------------- ### Install mime-db Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/mime-db/README.md Install the mime-db package using npm. ```bash npm install mime-db ``` -------------------------------- ### Install mime module Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/mime/README.md Install the mime module using npm. ```bash npm install mime ``` -------------------------------- ### Install array-flatten Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/array-flatten/README.md Install the array-flatten package using npm. ```bash npm install array-flatten --save ``` -------------------------------- ### Install depd Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/depd/Readme.md Install the depd module using npm. ```sh npm install depd ``` -------------------------------- ### Install os-tmpdir with npm Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/os-tmpdir/readme.md Install the os-tmpdir package using npm for use in your project. ```bash $ npm install --save os-tmpdir ``` -------------------------------- ### Install content-disposition Module Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/content-disposition/README.md Install the content-disposition module using npm. ```sh $ npm install content-disposition ``` -------------------------------- ### Install svgpath Package Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/svgpath/README.md Install the svgpath package using npm. ```bash npm install svgpath ``` -------------------------------- ### Install TypeScript Definitions Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/node_modules/raw-body/README.md Install TypeScript declaration files for raw-body and its Node.js dependency. ```sh npm install @types/node ``` -------------------------------- ### Install Accepts Module Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/accepts/README.md Install the accepts module using npm. This command is used for Node.js projects. ```sh npm install accepts ``` -------------------------------- ### Install isarray with component Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/isarray/README.md Install the isarray package using the component package manager. This command is used for projects managed with component.io. ```bash $ component install juliangruber/isarray ``` -------------------------------- ### Install svg-numbers with npm Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/svg-numbers/README.md Install the library using npm. This is the first step before using it in your project. ```bash $ npm install svg-numbers ``` -------------------------------- ### Install Bytes Utility Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/bytes/Readme.md Install the Bytes utility using npm. This is a Node.js module. ```bash $ npm install bytes ``` -------------------------------- ### Install node-md5 with npm Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/md5/README.md Install the md5 package using npm for use in Node.js projects. ```bash npm install md5 ``` -------------------------------- ### Load Default Font Synchronously (Node.js) Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/text-to-svg/README.md Loads the default IPA font synchronously for use in Node.js environments. This is a convenient way to get started without asynchronous operations. ```javascript const textToSVG = TextToSVG.loadSync(); const svg = textToSVG.getSVG('hello'); console.log(svg); ``` -------------------------------- ### Installing Dependencies and Running Tests Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/svg-path/README.md Provides the command-line instructions for cloning the repository, installing npm dependencies, and running the test suite for the svg-path library. ```bash $ git clone https://github.com/PPvG/svg-path $ cd svg-path $ npm install $ npm test ``` -------------------------------- ### Install Express using npm Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/Readme.md Installs the Express.js module locally using the npm package manager. ```bash $ npm install express ``` -------------------------------- ### Run Tests for iconv-lite Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/node_modules/iconv-lite/README.md Instructions for cloning the repository, installing dependencies, and running the test suite. Includes commands for performance and coverage testing. ```bash git clone git@github.com:ashtuchkin/iconv-lite.git cd iconv-lite npm install npm test # To view performance: node test/performance.js # To view test coverage: npm run coverage open coverage/lcov-report/index.html ``` -------------------------------- ### Basic Express Server Setup Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/Readme.md A minimal Express.js application that listens on port 3000 and responds with 'Hello World' to root requests. ```javascript var express = require('express') var app = express() app.get('/', function (req, res) { res.send('Hello World') }) app.listen(3000) ``` -------------------------------- ### Install and Run Stencilfy Locally Source: https://github.com/ttseng/stencilfy/blob/master/README.md Instructions for setting up and running Stencilfy on your local machine. ```bash npm install nodemon ``` -------------------------------- ### Start Development Server Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/opentype.js/CONTRIBUTING.md Start the development server to watch file changes, compile, and serve the project locally. This bundles source files under dist/opentype.js. ```bash npm start ``` -------------------------------- ### Send File for Download Example Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/content-disposition/README.md Create an HTTP server that sends a file for download, setting the appropriate Content-Type and Content-Disposition headers. ```js var contentDisposition = require('content-disposition') var destroy = require('destroy') var http = require('http') var onFinished = require('on-finished') var filePath = '/path/to/public/plans.pdf' http.createServer(function onRequest(req, res) { // set headers res.setHeader('Content-Type', 'application/pdf') res.setHeader('Content-Disposition', contentDisposition(filePath)) // send file var stream = fs.createReadStream(filePath) stream.pipe(res) onFinished(res, function (err) { destroy(stream) }) }) ``` -------------------------------- ### Simple Type Negotiation Example Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/accepts/README.md Demonstrates how to use accepts to negotiate the response type based on client's Accept header. The server's preferred types are listed in order. ```javascript var accepts = require('accepts') var http = require('http') function app (req, res) { var accept = accepts(req) // the order of this list is significant; should be server preferred order switch (accept.type(['json', 'html'])) { case 'json': res.setHeader('Content-Type', 'application/json') res.write('{"hello":"world!"}') break case 'html': res.setHeader('Content-Type', 'text/html') res.write('hello, world!') break default: // the fallback is text/plain, so no need to specify it above res.setHeader('Content-Type', 'text/plain') res.write('hello, world!') break } res.end() } http.createServer(app).listen(3000) ``` -------------------------------- ### Install mime-types Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/mime-types/README.md Install the mime-types module using npm. ```sh npm install mime-types ``` -------------------------------- ### Run Node.js Font Generation Example Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/opentype.js/examples/README.md Commands to run the `generate-font-node.js` example from the command line using Node.js. This generates a font file. ```bash cd opentype.js/examples node generate-font-node.js ``` -------------------------------- ### Install finalhandler Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/finalhandler/README.md Install the finalhandler module using npm. ```sh npm install finalhandler ``` -------------------------------- ### QS Module Usage Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/node_modules/qs/README.md Basic usage example demonstrating how to parse and stringify querystring data using the QS module. ```APIDOC ## QS Module Usage ### Description Demonstrates the fundamental use of the `qs` module for parsing a querystring into an object and stringifying an object back into a querystring. ### Method `require('qs')` ### Parameters None ### Request Example ```javascript var qs = require('qs'); var assert = require('assert'); var obj = qs.parse('a=c'); assert.deepEqual(obj, { a: 'c' }); var str = qs.stringify(obj); assert.equal(str, 'a=c'); ``` ### Response None ``` -------------------------------- ### Install http-errors Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/node_modules/raw-body/node_modules/http-errors/README.md Install the http-errors module using npm. ```bash npm install http-errors ``` -------------------------------- ### Express 1.0.0beta2 Release Notes Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express/History.md Highlights additions like more examples, exporting the Server constructor, and Server#helpers() for view locals. ```javascript * Added more examples * Added; exporting `Server` constructor * Added `Server#helpers()` for view locals * Added `Server#dynamicHelpers()` for dynamic view locals. Closes #349 * Added support for absolute view paths * Added; _home_ setting defaults to `Server#route` for mounted apps. Closes #363 * Added Guillermo Rauch to the contributor list * Added support for "as" for non-collection partials. Closes #341 * Fixed _install.sh_, ensuring _~/.node_libraries_ exists. Closes #362 [thanks jf] * Fixed `res.render()` exceptions, now passed to `next()` when no callback is given [thanks guillermo] * Fixed instanceof `Array` checks, now `Array.isArray()` * Fixed express(1) expansion of public dirs. Closes #348 * Fixed middleware precedence. Closes #345 * Fixed view watcher, now async [thanks aheckmann] ``` -------------------------------- ### Serve Files as Downloads Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/serve-static/README.md This snippet demonstrates how to serve all files from a directory as downloads by setting the 'Content-Disposition' header. ```javascript var contentDisposition = require('content-disposition') var finalhandler = require('finalhandler') var http = require('http') var serveStatic = require('serve-static') // Serve up public/ftp folder var serve = serveStatic('public/ftp', { 'index': false, 'setHeaders': setHeaders }) // Set header to force download function setHeaders (res, path) { res.setHeader('Content-Disposition', contentDisposition(path)) } // Create server var server = http.createServer(function onRequest (req, res) { serve(req, res, finalhandler(req, res)) }) // Listen server.listen(3000) ``` -------------------------------- ### ensureLinkSync Example Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/fs-extra/docs/ensureLink-sync.md This example demonstrates how to use ensureLinkSync to create a symbolic link. The function will create the destination directory structure if it does not already exist. ```javascript const fs = require('fs-extra') const srcpath = '/tmp/file.txt' const dstpath = '/tmp/this/path/does/not/exist/file.txt' fs.ensureLinkSync(srcpath, dstpath) // link has now been created, including the directory it is to be placed in ``` -------------------------------- ### Install Tmp Package Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/tmp/README.md Install the tmp package using npm. ```bash npm install tmp ``` -------------------------------- ### typeis() Examples Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/type-is/README.md Demonstrates various ways to use the typeis() function to check request content types against different type patterns. ```js // req.headers.content-type = 'application/json' typeis(req, ['json']) // 'json' typeis(req, ['html', 'json']) // 'json' typeis(req, ['application/*']) // 'application/json' typeis(req, ['application/json']) // 'application/json' typeis(req, ['html']) // false ``` -------------------------------- ### Full File Upload Example in Express Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/express-fileupload/README.md A complete example of setting up express-fileupload and handling a single file upload, including moving the file to a server directory. ```javascript const express = require('express'); const fileUpload = require('express-fileupload'); const app = express(); // default options app.use(fileUpload()); app.post('/upload', function(req, res) { if (!req.files) return res.status(400).send('No files were uploaded.'); // The name of the input field (i.e. "sampleFile") is used to retrieve the uploaded file let sampleFile = req.files.sampleFile; // Use the mv() method to place the file somewhere on your server sampleFile.mv('/somewhere/on/your/server/filename.jpg', function(err) { if (err) return res.status(500).send(err); res.send('File uploaded!'); }); }); ``` -------------------------------- ### fs-extra Copy Examples (Async/Sync) Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/fs-extra/README.md Shows how to use the fs-extra copy method with promises, callbacks, and synchronously. Choose the method that best suits your asynchronous or synchronous needs. ```javascript const fs = require('fs-extra') // Async with promises: fs.copy('/tmp/myfile', '/tmp/mynewfile') .then(() => console.log('success!')) .catch(err => console.error(err)) // Async with callbacks: fs.copy('/tmp/myfile', '/tmp/mynewfile', err => { if (err) return console.error(err) console.log('success!') }) // Sync: try { fs.copySync('/tmp/myfile', '/tmp/mynewfile') console.log('success!') } catch (err) { console.error(err) } ``` -------------------------------- ### Install forwarded module Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/forwarded/README.md Install the forwarded module using npm. ```sh npm install forwarded ``` -------------------------------- ### Install Debug Module Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/debug/README.md Install the debug module using npm. ```bash $ npm install debug ``` -------------------------------- ### Install Cookie Package Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/cookie/README.md Install the cookie package using npm. ```sh $ npm install cookie ``` -------------------------------- ### Example SVG Output Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/text-to-svg/README.md This is an example of the SVG output generated by the text-to-svg library. ```xml ``` -------------------------------- ### Express Serving from Multiple Roots Source: https://github.com/ttseng/stencilfy/blob/master/node_modules/serve-static/README.md This example shows how to configure Express to serve static files from multiple directories, prioritizing the first specified directory. ```javascript var express = require('express') var path = require('path') var serveStatic = require('serve-static') var app = express() app.use(serveStatic(path.join(__dirname, 'public-optimized'))) app.use(serveStatic(path.join(__dirname, 'public'))) app.listen(3000) ```