Skip to content

Commit

Permalink
Improve server middleware code example (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper De Moor authored and davidnagli committed Apr 16, 2018
1 parent c81eada commit 6156d39
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/i18n/en/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,19 @@ An example of using the parcel middleware with express
const Bundler = require('parcel-bundler');
const app = require('express')();

// Initialise a new bundler using a file and options (for options and file see the bundler documentation)
const bundler = new Bundler(file, options);
async function start() {
const file = 'index.html'; // Pass an absolute path to the entrypoint here
const options = {}; // See options section of api docs, for the possibilities

// Initialise a new bundler using a file and options
const bundler = new Bundler(file, options);

// Let express use the bundler middleware, this will let parcel handle every request over your express server
app.use(bundler.middleware());

// Let express use the bundler middleware, this will let parcel handle every request over your express server
app.use(bundler.middleware());
// Listen on port 8080
app.listen(8080);
}

// Listen on port 8080
app.listen(8080);
start();
```

0 comments on commit 6156d39

Please sign in to comment.