A simple User API using REST to perform CRUD operations on user data with an SQLite database.
Before running the app:
# Install all dependencies
npm i
# Optionally load in some mock data (will drop and create a new db)
npm run db:reloadThere is an option to add an .env file to support various base urls and ports:
BASE_URL=
PORT=
Alternatively, if using bun (recommended), replace npm with bun. The versions we recommend are:
"engines": {
"node": "22.x",
"bun": "1.2.x"
}
The command below will start the server http://localhost:3000 or a configured <BASE_URL>:<PORT> as mentioned previously.
npm run dev-
GET
/users: Get N users (defaults to 10)curl --location 'http://localhost:3000/users?limit=5' -
GET
/user/:id: Fetches a user by their unique IDcurl --location 'http://localhost:3000/user/1' -
POST
/user: Creates a new usercurl --location 'http://localhost:3000/user/' \ --header 'Content-Type: application/json' \ --data-raw '{ "firstName": "Foo", "lastName": "Bar", "email": "foo.bar@gmail.com", "phone": "111-111-1111" }'
-
PATCH
/user/:id: Updates user informationcurl --location --request PATCH 'http://localhost:3000/user/1' \ --header 'Content-Type: application/json' \ --data '{ "phone": "111-222-3333" }'
-
PATCH
/user/:id/status: Activates a usercurl --location --request PATCH 'http://localhost:3000/user/1/status' -
DELETE /user/:id: Deletes a user
curl --location --request DELETE 'http://localhost:3000/user/1'