Skip to content
Project template·Pro

Express + SQLite tasks API

A tasks API on Express 5 with filtering, paging and tests. Data goes to node:sqlite, so nothing native has to compile. It needs the Linux environment with Node.js 22.13 or newer, and npm install fetches about 3.5 MB.

You need PocketCode Pro to install it.

If PocketCode is installed on your Android device, this opens the page in the app.

Preview

Files

README.md
package-lock.json
package.json
server.js
src/app.js
src/db.js
src/errors.js
src/routes/tasks.js
src/validate.js
test/tasks.test.js

README.md

# Tasks API: Express + SQLite A REST API for tasks with Express 5 and SQLite: create, list, read, update and delete tasks, filter the list by state, tag or text, and page through it. Input is checked and errors come back as JSON. The database is `node:sqlite`, which is built into Node.js 22.13 and newer, so the only package is Express (about 65 small packages, 3.5 MB, all JavaScript). Comes with tests. ## Run it in PocketCode You need the app's Linux environment with Node.js 22.13 or newer and npm (the Developer pack in Terminal › Linux includes both). Check with `node --version`. 1. Open the terminal in this project's folder (Open Terminal Here, in the editor menu). 2. Install Express (needs internet the first time): ```sh npm install ``` 3. Start the server: ```sh npm start ``` The terminal shows `Tasks API on http://localhost:3000`. `npm run dev` does the same and restarts it when you save a file. Some Node.js versions also print `ExperimentalWarning: SQLite is an experimental feature`; the API works the same. 4. Open http://localhost:3000 in the DevBrowser (or in the phone's browser) to see the list of endpoints. To try the API, open a second terminal tab: ```sh curl -X POST localhost:3000/api/tasks -H 'content-type: application/json' -d '{"title":"Buy milk","tag":"home"}' curl 'localhost:3000/api/tasks?done=false' curl -X PATCH localhost:3000/api/tasks/1 -H 'content-type: application/json' -d '{"done":true}' ```

This preview is shortened. You get the full content when you install it.

Changes in 1.0.0

First version.

Related

Node.js JSON API without dependenciesProProject templateA notes API on node:http: create, list, update and delete notes, with input checks and JSON errors, saved to a file. You don't install anything. Tap Run on server.js and the app's own Node.js starts it on localhost:3000. The project includes tests.Markdown static siteProProject templateWrite pages in Markdown and build them into a static HTML site with a shared layout and menu. The build is about 110 lines of Node.js you can edit, and its only package is marked. You open the result in the DevBrowser. The first npm install needs the Linux environment.To-do list in plain JavaScriptProProject templateA to-do list in plain JavaScript modules. You can add items, edit them in place, tick them off, filter and clear them, and the list is saved in localStorage. The logic has tests for Node's test runner. It runs in the DevBrowser and on the app's own Node.js, without Linux.FastAPI link shortenerProProject templateA link shortener in Python with FastAPI and SQLite: it creates short codes, redirects and counts clicks. It comes with a one-page form and pytest tests. It needs Python 3.10 or newer with pip in the Linux environment and installs 14 pinned packages.Flask + SQLite web appProProject templateA reading list in Flask with server-rendered pages and plain forms, SQLite storage and a small JSON API. The tests use Flask's test client. It needs Python and pip in the Linux environment and installs 7 pinned packages.Python CLI with SQLiteProProject templateAn expense tracker for the terminal. It adds and lists expenses, totals them per category each month and exports CSV. It only uses the standard library (argparse, sqlite3), so there's nothing to pip install, and it has unittest tests. It needs Python in the Linux environment.