A simple, naïve, in-memory RESTful guest list API in Express.
git clone https://github.com/upleveled/express-guest-list-api-memory-data-store.git
cd express-guest-list-api-memory-data-store
pnpm install
pnpm start
const baseUrl = 'http://localhost:4000';
const response = await fetch(`${baseUrl}/guests`);
const allGuests = await response.json();
const response = await fetch(`${baseUrl}/guests/:id`);
const guest = await response.json();
const response = await fetch(`${baseUrl}/guests`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ firstName: 'Karl', lastName: 'Horky' }),
});
const createdGuest = await response.json();
const response = await fetch(`${baseUrl}/guests/1`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ attending: true }),
});
const updatedGuest = await response.json();
const response = await fetch(`${baseUrl}/guests/1`, { method: 'DELETE' });
const deletedGuest = await response.json();
- Click "Fork" at the top right of the
express-guest-list-api-memory-data-store
GitHub repository page, select your GitHub account and click "Fork" to create a copy of the GitHub repository in your account - On Deno Deploy - Create a New Project, click on "Continue with GitHub", authorize Deno Deploy to access your GitHub account and accept the terms and conditions
- If your account doesn't appear in the "Select User or Organization" dropdown, select "Add GitHub Account", and then on the authorization page on GitHub, select your GitHub account, choose "Only select repositories" and select the repository
express-guest-list-api-memory-data-store
from the dropdown, which will return you to the new project page - Select your GitHub account in the dropdown and click on "Select" next to the forked repository
express-guest-list-api-memory-data-store
- In the "Entrypoint" dropdown near the bottom of the page, select
index.ts
and click "Deploy Project" - After successful deployment, a "Success" page will appear - click "Go to Project" to continue to the project overview page
The API URL is on the project overview page under "Production Deployment" - it's the second (shorter) URL which ends with .deno.dev