An open API service indexing awesome lists of open source software.

https://github.com/okamyuji/json-server-custom

A customizable mock API server built with Node.js and json-server. Provides RESTful endpoints for managing users, products, and orders with data persistence and easy local development.
https://github.com/okamyuji/json-server-custom

backend development json-server mock-api nodejs rest-api webserver

Last synced: about 2 months ago
JSON representation

A customizable mock API server built with Node.js and json-server. Provides RESTful endpoints for managing users, products, and orders with data persistence and easy local development.

Awesome Lists containing this project

README

          

# JSON Server Custom

カスタマイズされたJSON Serverを使用したモックAPIサーバー。ユーザー、商品、注文データを管理するRESTful APIを提供します。

## 機能

- カスタムルーティング
- 複数のデータエンドポイント(ユーザー、商品、注文)
- IDの重複チェック
- JSON形式でのデータ永続化
- データの更新(PUT)機能

## エンドポイント

各エンドポイントで以下のHTTPメソッドが利用可能です:

### GET

- `/users` - ユーザー情報の取得
- `/products` - 商品情報の取得
- `/orders` - 注文情報の取得

### POST

新規データの作成。IDの重複がある場合はエラーを返します。

### PUT

既存データの更新。指定されたIDのデータを更新します。

使用例:

```bash
# データの更新
curl -X PUT -H "Content-Type: application/json" -d '{"id": 1, "name": "Updated Name"}' http://localhost:3000/users
```

## データ構造

### Users

```json
{
"id": 1,
"name": "Alice"
}
```

### Products

```json
{
"id": 1,
"name": "Laptop",
"price": 1000
}
```

### Orders

```json
{
"id": 1,
"userId": 1,
"orderDate": "2024-02-15",
"items": [
{
"productId": 1,
"quantity": 1,
"price": 1000
}
],
"totalAmount": 2000,
"status": "delivered"
}
```

## セットアップ

- 依存パッケージのインストール

```bash
npm install
```

- サーバーの起動

```bash
npm start
```

サーバーは `http://localhost:3000` で起動します。

## 技術スタック

- Node.js
- json-server (v0.17.4)
- nodemon (開発用)

## 開発

このプロジェクトは `nodemon` を使用して開発しています。ファイルの変更を検知して自動的にサーバーを再起動します。