Skip to content

Latest commit

Β 

History

History
91 lines (67 loc) Β· 2.54 KB

File metadata and controls

91 lines (67 loc) Β· 2.54 KB

Full-Stack Node.js CRUD (SAP Build Code friendly)

A minimal full‑stack app using Express (Node.js) + SQLite backend and React (Vite) frontend. It implements CRUD for a simple Task entity.

Works great locally, in VS Code, and in SAP Business Application Studio (Dev Space: Node.js / Full-Stack). You can also deploy the server to SAP BTP (Cloud Foundry) and serve the built React app from the same process.


πŸ“¦ Project structure

node-crud-fullstack-sap-build/
β”œβ”€ server/                # Express + SQLite API
β”‚  β”œβ”€ src/
β”‚  β”‚  β”œβ”€ index.js         # App entry, mounts /api/tasks
β”‚  β”‚  └─ routes/tasks.js  # CRUD routes
β”‚  β”œβ”€ src/db.js           # SQLite init
β”‚  β”œβ”€ package.json
β”‚  └─ .env                # PORT=4000
└─ client/                # React + Vite UI
   β”œβ”€ src/
   β”‚  β”œβ”€ components/
   β”‚  β”‚  β”œβ”€ TaskForm.jsx
   β”‚  β”‚  └─ TaskList.jsx
   β”‚  β”œβ”€ App.jsx
   β”‚  β”œβ”€ api.js
   β”‚  └─ main.jsx
   β”œβ”€ index.html
   β”œβ”€ vite.config.js
   └─ package.json

πŸƒβ€β™‚οΈ Run locally (two terminals)

Terminal A – API

cd server
npm install
npm run dev   # starts http://localhost:4000

Terminal B – Frontend

cd client
npm install
npm run dev   # opens http://localhost:5173, proxy to /api

πŸ§ͺ Test API quickly

After starting the server, try:

curl -X POST http://localhost:4000/api/tasks        -H 'Content-Type: application/json'        -d '{"title":"First task","description":"Hello"}'

curl http://localhost:4000/api/tasks

πŸ—οΈ Build for production

# Build static frontend
cd client && npm install && npm run build

# Start server in production mode (serves client/dist)
cd ../server
NODE_ENV=production npm start
# Open http://localhost:4000

🧰 Use in SAP Business Application Studio

  1. Create a Node.js dev space.
  2. Upload or clone this project.
  3. Open two terminals and follow the local run steps above.
  4. Optional: configure a Cloud Foundry target and push the server with a manifest.yml (bind to a SQLite-compatible persistent storage or migrate to SAP HANA Cloud / PostgreSQL). Frontend build can be served by the same Express app.

πŸ”Œ API surface

  • GET /api/tasks – list tasks
  • GET /api/tasks/:id – fetch one
  • POST /api/tasks – create { title, description?, status? }
  • PUT /api/tasks/:id – update any of { title, description, status }
  • DELETE /api/tasks/:id – remove

πŸ“„ License

MIT β€” use freely.