This example demonstrates usage of the following @dandi packages:
@dandi/core@dandi/mvc@dandi-contrib/mvc-express@dandi/model-builder
From a command line in the
[dandi-project-root]/_examples/simple-express-rest-api directory:
- run
npm installif you haven't already - run
npm start - The server should be accessible from
http://localhost:7080/
GET http://localhost:7080/data- list all entriesPOST http://localhost:7080/data- create an entryGET http://localhost:7080/data/:id- get the specified entryPUT http://localhost:7080/data/:id- replace the specified entryDELETE http://localhost:7080/data/:id- delete the specified entry
This file is used as the entry point for the application. It loads and starts the container.
This file is used to construct the @dandi DI container used to run
the application. It pulls in the MVC service implementations from
@dandi/mvc and @dandi-contrib/mvc-express, validation implementations from
@dandi/model-builder, as well as the controller used in
the application itself.
Defines the DataModel and DataModelRequest models. Note the
decorators from @dandi/model used to define properties in the model
classes.
Defines the DataService which is used in this application a simple
data repository.
Provides access to DataService by defining a RESTful API accessible
via HTTP.