प्रोजेक्ट टेम्पलेट·Pro
बिना डिपेंडेंसी का Node.js JSON API
node:http पर नोट्स API: बनाना, सूची, बदलना और हटाना, इनपुट जाँच और JSON एरर के साथ, डेटा एक फ़ाइल में सेव होता है। कुछ इंस्टॉल नहीं करना: server.js पर Run टैप करें, ऐप का अपना Node.js इसे localhost:3000 पर चालू कर देगा। टेस्ट भी शामिल हैं।
इसे इंस्टॉल करने के लिए PocketCode Pro चाहिए।
अगर आपके Android डिवाइस पर PocketCode इंस्टॉल है, तो यह पेज ऐप में खुलेगा।
प्रीव्यू
फ़ाइलें
README.md
package.json
server.js
src/app.js
src/store.js
test/api.test.jsREADME.md
# Notes API on Node.js, no dependencies A JSON API for notes built on `node:http`: create, list, read, update and delete, with input checks, clear error messages and a request log. Notes are saved to `data/notes.json` after every change. There is nothing to install: no npm packages, no framework. ## Run it in PocketCode 1. Open `server.js` and tap Run. The app's own Node.js starts it; the Run panel shows `Notes API on http://localhost:3000`. 2. Open `http://localhost:3000` in the DevBrowser (or in the phone's browser) to see the list of endpoints. 3. Try the API from the terminal, or from any HTTP client: ```sh curl -X POST localhost:3000/api/notes -H 'content-type: application/json' -d '{"text":"Buy milk"}' curl localhost:3000/api/notes ``` 4. Tap Stop in the Run panel to end it. You don't need the Linux environment to run the server. `curl` and `npm` are in the terminal's Linux environment with Node.js. ## Run the tests - Open `test/api.test.js` and tap Run. - Or, in the terminal: `npm test`. The tests start the server on a free port with the notes in memory, so they never touch `data/notes.json`. ## Endpoints | Method and path | Body | Answer | |---|---|---| | `GET /health` | | `{"ok": true}` | | `GET /api/notes` | | All notes, oldest first | | `POST /api/notes` | `{"text": "..."}` | 201 and the new note | | `GET /api/notes/:id` | | The note, or 404 | | `PATCH /api/notes/:id` | `{"text"?: "...", "done"?: true}` | The updated note |यह प्रीव्यू छोटा किया गया है। पूरा कंटेंट इंस्टॉल करने पर मिलेगा।
1.0.0 में बदलाव
पहला संस्करण।