Skip to content

upleveled/express-guest-list-api-memory-data-store

Repository files navigation

Express REST Guest List API

A simple, naïve, in-memory RESTful guest list API in Express.

Installation

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

Usage

Base URL

const baseUrl = 'http://localhost:4000';

Getting all guests (aka GET /guests)

const response = await fetch(`${baseUrl}/guests`);
const allGuests = await response.json();

Getting a single guest (aka GET /guests/:id)

const response = await fetch(`${baseUrl}/guests/:id`);
const guest = await response.json();

Creating a new guest (aka POST /guests)

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();

Updating a guest (aka PUT /guests/:id)

const response = await fetch(`${baseUrl}/guests/1`, {
  method: 'PUT',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ attending: true }),
});
const updatedGuest = await response.json();

Deleting a guest (aka DELETE /guests/:id)

const response = await fetch(`${baseUrl}/guests/1`, { method: 'DELETE' });
const deletedGuest = await response.json();

Deploy on Deno Deploy

  1. 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
  2. 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
  3. 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
  4. Select your GitHub account in the dropdown and click on "Select" next to the forked repository express-guest-list-api-memory-data-store
  5. In the "Entrypoint" dropdown near the bottom of the page, select index.ts and click "Deploy Project"
  6. 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

Related

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published