@dankolz/data-service-server

1.0.1 • Public • Published

Data Service Server

A server component to allow access over HTTP to any AbstractDataService and client code to call the server side. Allows web clients to treat a server side database is if it were local.

Install

npm install @dankolz/data-service-server

Server side usage

import ServerDataService from '@dankolz/data-service-server'

let server = new ServerDataService({
	dataService: the-underlying-store
})
let serviceRouter = express.Router()
server.addToRouter(serviceRouter)
app.use('/my-data-url', serviceRouter)

There are several storage mechanism that implement AbstractDataService including MongoDB and an in-memory store.

Client side usage

import RemoteDataService from '@dankolz/data-service-server'
// or import RemoteDataService from '@dankolz/data-service-server/client-lib/remote-data-service.mjs'
let serv = new RemoteDataService({
	urlPrefix: '/my-data-url'
})

let results = await serv.fetch({name: 'Dan'})
// ...etc

Options

There are a bunch of options for security and transforming the objects sent and received. Check the constructors for documentation of the options.

Notes

See AbstractDataService or MongodbDataService for usage examples.

Data sent over http is transformed when serialized. Dates become strings. IDs become strings. Complex objects may be lost altogether. Use the presaveTransformer and postfetchTransformer options to mitigate that problem.

Readme

Keywords

none

Package Sidebar

Install

npm i @dankolz/data-service-server

Weekly Downloads

64

Version

1.0.1

License

ISC

Unpacked Size

17.8 kB

Total Files

18

Last publish

Collaborators

  • dankolz