Back to articles
mockapi-local: Get a Full REST API From a JSON Schema in One Command

mockapi-local: Get a Full REST API From a JSON Schema in One Command

via Dev.to WebdevHasan Ayvaz

Every frontend developer knows the pain. You're building a new feature. The backend isn't ready yet. So you either wait, write a bunch of hardcoded JSON files, or spin up a fake server that takes an hour to configure. Every time. I got tired of this loop, so I built mockapi-local — a CLI tool that takes a JSON schema file and instantly gives you a fully working REST API with realistic fake data. What It Does You describe your data model in a schema.json file: { "resources" : { "users" : { "count" : 20 , "fields" : { "id" : "uuid" , "name" : "fullName" , "email" : "email" , "role" : { "type" : "enum" , "values" : [ "admin" , "user" , "moderator" ] }, "createdAt" : "pastDate" }, "relations" : { "posts" : "posts" } }, "posts" : { "count" : 50 , "fields" : { "id" : "uuid" , "title" : "sentence" , "body" : "paragraph" , "userId" : { "type" : "ref" , "resource" : "users" } } } }, "config" : { "delay" : 200 , "errorRate" : 0.05 } } Run one command: mockapi-local serve schema.json --port 3000

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
4 views

Related Articles