1.0.5 • Published 1 year ago

pretty-path-express v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Prettify a path for Express etc.

Created function, returning full path for transfering it to express.render() or others. By the default, different servers use different slashes for pathname: '/' or '\', but getPath() function fixes this dependency. So we can give it our path and get the full path result back.

Usage:

  1. Import prettyPath from pretty-path-express module.
  2. Set the base dirname value, using prettyPath.setDirname(path[])
  3. Use the prettyPath.getPath(to) to get correct full path

Example:

npm install pretty-path-express

const express = require('express');
const app = express();
const prettyPath = require('pretty-path-express');
prettyPath.setDirname(__dirname, 'views');

app.get('/', (req, res) => {
  const fullPath = prettyPath.getPath('index.html');
  res.render(fullPath);
});

Therefore, prettyPath.getPath returns full path value ... your dirname/views/index.html

Author: maiklr1ch

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago