Skip to content

Generate Express.js-compatible route middleware for JSData models.

License

Notifications You must be signed in to change notification settings

js-data/js-data-express

Repository files navigation

js-data logo

js-data-express

Slack Status npm version Circle CI npm downloads Coverage Status

Generate Express.js-compatible route middleware for js-data models.

To get started, visit http://js-data.io.

import express from 'express';
import { mount, queryParser, Router } from 'js-data-express';
import { Container } from 'js-data';

const app = express();
const store = new Container();
const UserMapper = store.defineMapper('user');
const CommentMapper = store.defineMapper('comment');
// Mount queryParser and store at "/"
mount(app, store);

// Mount queryParser and store at "/api"
mount(app, store, '/api');

// Mount queryParser at "/"
app.use(queryParser);
// Mount store at "/"
app.use(new Router(store).router);

// Mount queryParser at "/api"
app.use('/api' queryParser);
// Mount store at "/api"
app.use('/api', new Router(store).router);

// Create an express Router instance
const api = express().Router();
// Mount queryParser
api.use(queryParser);
// Mount UserMapper at "/api/user"
api.use('/user', new Router(UserMapper).router);
// Mount UserMapper at "/api/comment"
api.use('/comment', new Router(CommentMapper).router);
// Use api Router in an existing express app instance
app.use('/api', api);

Links

License

The MIT License (MIT)

Copyright (c) 2016-2017 js-data-express project authors

About

Generate Express.js-compatible route middleware for JSData models.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •