# @andrewsosa/todo-server

> [![npm version](https://badge.fury.io/js/%40andrewsosa%2Ftodo-server.svg)](https://badge.fury.io/js/%40andrewsosa%2Ftodo-server)

Latest version **1.0.2** (published 2019-09-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @andrewsosa/todo-server
pnpm add @andrewsosa/todo-server
yarn add @andrewsosa/todo-server
bun add @andrewsosa/todo-server
```

Provides the command `todo-server`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-09-07 |
| First published | 2019-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | andrewsosa |
| Maintainers | andrewsosa |

## Links

- npm: https://www.npmjs.com/package/@andrewsosa/todo-server
- Repository: https://github.com/andrewsosa/todo-server
- Homepage: https://github.com/andrewsosa/todo-server#readme
- Issues: https://github.com/andrewsosa/todo-server/issues
- npm.io page: https://npm.io/package/@andrewsosa/todo-server

## Dependencies (5)

- [boxen](https://npm.io/package/boxen.md) ^4.1.0
- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [micro](https://npm.io/package/micro.md) ^9.3.4
- [get-port](https://npm.io/package/get-port.md) ^5.0.0
- [micro-morgan](https://npm.io/package/micro-morgan.md) ^0.1.0

## Recent versions

- 1.0.2 (latest) — 2019-09-07
- 1.0.1 — 2019-09-07
- 1.0.0 — 2019-09-06

## README

# To Do List Microservice Server Example
[![npm version](https://badge.fury.io/js/%40andrewsosa%2Ftodo-server.svg)](https://badge.fury.io/js/%40andrewsosa%2Ftodo-server)

A todo list API microservice in <100 lines of Javascript.


### Usage
The API repsonds to GET, POST, PATCH, DELETE at any route.

* GET: Returns list of all todos
* POST: Create a todo
* PATCH: Change a todo's done status.
* DELETE: Remove a todo.

```js
const API = "http://localhost:3000";

// Create a todo
axios
  .post(API, { todo: "Finish side project" })
  .then(resp => resp.data)
  .then(data => console.log(data));
  //    {
  //      total: 1,                                 // total todos
  //      id: 'dad11e35bef81e7620fae012cbbf65f6',   // random id
  //      done: false,                              // status
  //      todo: 'finish side project'               // original text
  //    }

// Get all todos
axios
  .get(API)
  .then(resp => resp.data)
  .then(data => console.log(data));
  // [
  //     {
  //         id: 'dad11e35bef81e7620fae012cbbf65f6',
  //         done: false,
  //         todo: 'finish side project'
  //     },
  //     {
  //         id: '57e130216cb5aba21ec33f971b598985',
  //         done: false,
  //         todo: 'finish side project'
  //     },
  //     ...
  // ]

// Update a todo's done status
axios
  .patch(API, { id: "57e130216cb5aba21ec33f971b598985", done: "true" })
  .then(resp => console.log(resp.status));
  // 202 (no response body, only status code)

// Remove a todo
axios
  .delete(API, { data: { id: "57e130216cb5aba21ec33f971b598985" } })
  .then(resp => console.log(resp.status));
  // 202 (no response body, only status code)

```

---
_Source: https://npm.io/package/@andrewsosa/todo-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
