Modelo de projeto·Pro
API de tarefas com Express e SQLite
Uma API de tarefas em Express 5 com filtros, paginação e testes. Os dados vão para o node:sqlite, então não há nada nativo para compilar. Precisa do ambiente Linux com Node.js 22.13 ou mais recente, e o npm install baixa cerca de 3,5 MB.
Para instalar, você precisa do PocketCode Pro.
Se o PocketCode estiver instalado no seu Android, isto abre a página no app.
Prévia
Arquivos
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.jsREADME.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}' ```Esta prévia está encurtada. O conteúdo completo vem com a instalação.
Mudanças na 1.0.0
Primeira versão.