dw0n
v1.0.2
Published
A simple and fast project initializer for dev_web0n
Readme
🛡️ dev_web0n
A smart fake auth & API service to supercharge your frontend — without writing real backend code.
🚀 Overview
dev_web0n dev_web0ns a lightweight mock server that provides:
- 🔐 Token-based authentication endpoints
- 📦 RESTful APIs for testing (users, products, posts, etc.)
Ideal for frontend developers, rapid prototyping, or teaching/demo purposes.
📦 Features
- Token-based fake login/signup
- Fully extensible architecture for custom data and routes
🛠️ Quick Start
"If you want to easily use the dev_web0n, create a folder with any name, open your terminal inside that folder, and run this command."
🛠️ Getting Started
npx dw0n
npm install
npm start📦 Project Setup Overview
If everything is working correctly, you should see four new files/folders generated:
endpointfiledatafolderinfo.configfile (this is the schema file — explained later)package.json
As a web developer, you likely already understand the purpose of the package.json file — it defines your project's metadata, scripts, and dependencies.
🔗 endpoint file
This is the main entry point for calling the server. Inside, you'll see a line like this:
import dev_web0n from 'dev_web0n';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
dev_web0n({
auth: false,
dir: __dirname,
port: 3000,
});This function takes three properties:
auth: If set totrue, the server will perform user authentication on every request. If set tofalse, no authentication will occur.dir: This represents the current directory of your project. Do not modify this — just keep it as is.port: This is the port on which your server will run. You can change it to any valid port number according to your preference.
📁 data folder
You’ll rarely (if ever) need to modify this folder.
It is generated and managed based on your info.config file.
If you face data-related issues, you can modify it manually — it’s entirely up to you. But in most cases, it should work automatically.
⚙️ info.config file (Schema Configuration)
This is the most important configuration file for your data structure.
Inside info.config, you’ll define schemas for your collections (or "tables").
For example, if you have an orders table with fields like userName, productName, and totalAmount, you’ll write:
orders = [userName, productName, totalAmount]To define more tables, write each on a new line:
products = [title, description, price]
orders = [userName, productName, totalAmount]You do not need to include an
idfield. Anidwill be automatically generated for each entry.
✅ Final Note
This setup allows for a fast, configurable data server with optional authentication.
You only need to adjust the info.config file for your desired data schema — the rest is handled for you!
🔐 Authentication & Data Fetching Guide
Wait! You do not need to create any signup or login tables manually. Authentication is built-in and fully managed for you.
⚠️ Important Note on Authentication
📢 But wait! If you set
auth: truein yourendpointfile, then you must include the following in every request header:
✅ Sending TCR Token
headers: {
Authorization: `tcr YOUR_TOKEN`;
}🕒 Token Validity
Your token will remain valid for 1 day. ⛔ We apologize for not allowing you to control the token expiration time at this stage. However, we hope to fix this limitation in a future update, where you’ll be able to customize the duration as needed.
🎯 Additionally, more exciting features will be introduced in upcoming updates to enhance your overall experience!
🔑 Authentication Flow
👥 Register a New User
POST /signup
Required fields (in the request body):
{
"name": "demoName",
"email": "[email protected]",
"password": "yourStrongPassword123"
}- Passwords are securely encrypted using
bcryptjs. - You will receive the following response after a successful signup:
{
"name": "******",
"email": "****@gmail.com",
"id": "*****",
"tokenId": "S79aqtsHEPUDioqdcP31rzKa2U",
"accessTime": "*****",
"isTrue": true,
"message": "Signup successful! 🎉✅🚀 Welcome aboard!"
}🛂 User Login
Endpoint:
POST /login
Required fields:
emailpassword
Example Request:
{
"email": "[email protected]",
"password": "bestPassw0rd"
}Example Response:
{
"name": "*****",
"email": "*****@gmail.com",
"id": "*****",
"tokenId": "pvwkiXCCMZdyZwvVS3MxGfvBGx",
"accessTime": "*****"
}🌐 How to Fetch Data
Now that your configuration is ready, let’s talk about fetching data.
When you start your server, your terminal will display a URL like:
http://localhost:3000Here,
3000is the port defined in yourendpointfile. You can use this base URL to fetch data from your tables.
To perform operations like GET, POST, PATCH, or DELETE, simply use:
http://localhost:3000/tableName📦 Example: POST request to products table
fetch('http://localhost:3000/products', {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
Authorization: `tcr YOUR_TOKEN`,
},
});You can now perform all standard operations on any table you define in info.config.
