Integrate Nobox into your Javascript/Typescript project
You can clone or study our nobox example project
Install nobox client
npm i nobox-client
if you haven'tGo to nobox.cloud or your local Nobox console, register and copy the token provided
Create a folder and name it
nobox
or anything elseCreate a
config.ts
file in thenobox
folder you created and add the following code:import { Config, getFunctions, getSchemaCreator } from "nobox-client"; export const config: Config = { endpoint: "https://api.nobox.cloud", // or http://localhost:8000 if you are running local project: "[yourproject]", //Replace [yourProject] with your desired project name token: "[yourToken]", //Replace [yourtoken] with the token you copied in step 2 }; export const createRowSchema = getSchemaCreator(config, { type: "rowed" }); export const createKeyGroupSchema = getSchemaCreator(config, { type: "key-group" }); export const Nobox = getFunctions(config);
Create a folder called
record-structures
(or any other name) inside the nobox folderCreate a file inside the
record-structures
folder and name ituser.ts
(or any other name). This is just an example.Copy the following code into the
user.ts
file. You can modify the structure as needed:import { Space } from "nobox-client"; import { createRowSchema } from "../config"; interface User { email: string; password: string; firstName: string; age: number; } export const UserStructure: Space<User> = { space: "User", description: "A Record Space for Users", structure: { email: { description: "User's Email", type: String, required: true }, password: { description: "User's Password", required: true, type: String, hashed: true }, firstName: { description: "User's First Name", required: true, type: String, }, age: { description: "User's Age", required: false, type: Number, } } } export const UserModel = createRowSchema<User>(UserStructure);
After following these steps, your project folder structure should look like the tree representation below::
. ├── nobox │ ├── config.ts │ └── record-structures │ ├── app-details.ts │ ├── cars.ts │ └── user.ts ├── package.json