A simple example of a RESTful API that handles TODO list of items. It's built using TypeScript, expressjs and mongoosejs.
- Yarn installed on your machine.
- MongoDB account so you can create a mongodb cluster
clustertodo
and a user. - PostMan or Insomnia or simply
curl
to invoke the API endpoints.
- Clone the repository:
git clone git@github.com:safaa-alnabulsi/todo-api.git
- Install the application:
yarn install
- Place your own MongoDB User credentials in
nodemon.json
{
"env": {
"MONGO_USER": "<Username>",
"MONGO_PASSWORD": "<password>",
"MONGO_DB": "clustertodo"
}
}
- Build the project and start the server:
yarn build && yarn start
- Open Insmonia and make a
GET
request tohttp://localhost:4000/todos/
. It will like the image below after you add your endpoints and couple of todos:
Method | End-Point | Description |
---|---|---|
GET |
/todos |
List all todos |
POST |
/todos |
Create a new todo |
GET |
/todos/:id |
Fetch a specific todo |
PUT |
/todos/:id |
Edit existing todo |
PATCH |
/todos/:id |
Mark an existing todo as complete |
DELETE |
/todos/:id |
Delete existing todo |
To add the following:
- Authentication
- Etags
- JSON Schema
-
mongoose: https://mongoosejs.com/
-
express: https://expressjs.com
-
supertest: https://yarnpkg.com/package/supertest
-
sinon-mongoose: https://www.npmjs.com/package/sinon-mongoose
-
mocking mongoose: https://getsimple.works/how-to-stub-mongoose-methods-and-mock-document-objects
-
Automating Dependabot with Github Action: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions
-
semnatic-release:
-
eslint: https://khalilstemmler.com/blogs/typescript/eslint-for-typescript/
-
commit for pure test: test major release - test with BREAKING CHANGE Note: Your commits must be formatted exactly as specified by the chosen convention. For example the Angular Commit Message Conventions require the BREAKING CHANGE keyword to be followed by a colon (:) and to be in the footer of the commit message. let's try again!!!