1.8.0 • Published 1 month ago
@dhruv-m-patel/web-app v1.8.0
@dhruv-m-patel/web-app
A package to spin up an express web server for your application
Built with express, typescript and webpack providing following features:
- Configure your web-app with universal/isomorphic rendering support
- Built-in webpack support - hot reloading included
- Uses directory-based routing, which fosters clarity in implementing your route handlers
- Built-in, optional session support
- Built-in, optional static directory support to host your static assets with application code and serve them publicly
- Allows adding your own custom application logic easily through one-time configuration in app startup options
- Assigns unique id to each request for providing request traceability
- Adds final error handler at the end of the app setup to ensure all unhandled route errors are caught and logged
Using the package
Install the package:
npm i -S @dhruv-m-patel/web-app
Update your
app.ts
file (main application file) to export configuration as below:import path from 'path'; import { Application } from 'express'; import { configureApp } from '@dhruv-m-patel/web-app'; const app: Application = configureApp({ paths: { // specify directory containing file-based routing structure for your app routes: path.resolve(__dirname, './routes'), // specify static directory where scripts / styles / images would be found staticDirectories: [path.resolve(__dirname, '../../static')], }, setup: (webApp) => { // Your custom app setup code goes here }, }); export default app;
Update your
server.ts
orindex.ts
file (the file that starts the server) to run your application like this:import app from './app'; import { runApp } from '@dhruv-m-patel/web-app'; const port: number = Number(process.env.PORT) || 3000; runApp(app, { appName: 'Web App', port});
1.8.0
1 month ago
1.7.0
2 months ago
1.5.2
2 months ago
1.6.0
2 months ago
1.5.1
2 months ago
1.5.0
3 months ago
1.4.13
3 months ago
1.4.12
3 months ago
1.4.11
3 months ago
1.4.10
3 months ago
1.4.9
6 months ago
1.4.8
6 months ago
1.4.7
1 year ago
1.4.6
1 year ago
1.4.5
1 year ago
1.4.4
1 year ago
1.2.1
2 years ago
1.2.0
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.0.1
2 years ago