The Rest Api
For this tutorial, we’ll use Express (Remult works with many JavaScript web frameworks including Express, Fastify, Next.js, Sveltekit, nuxt.js, Hapi, Hono, Nest, and Koa).
Open backend/index.ts
and add the following lines to include the Task
in the REST API:
Code Explanation
- We import the necessary
remultExpress
module for integrating Remult with Express. - We import the
Task
entity from theshared
folder. - We use the
remultExpress
function to set up the Remult REST API and register theTask
entity in itsentities
array. - Finally, we tell Express to use the API with
app.use(api)
.
See that it works
Click on the Test the Api
button in the preview window, you should see an empty JSON array in the result.
You can also open the
network
tab in the developer tools and see the requests that are being sent to the nodejs server
Files
Preparing Environment
- Installing dependencies
- Starting http server