To get started with NoonJS, make sure you have the following installed on your system:
Open a terminal and run the following command to create a new project. If you don't have a config.json, noonjs will generate a default one for you.
Replace your MongoDB connection string in the .env file or config.json. In production, use environment variables to securely pass it.
The default configuration should look like this.
{
"auth": {
"collection": "users",
"secret": "your-primary-secret",
"refreshsecret": "your-secondary-secret",
"username": "username",
"password": "password",
"access": 900,
"refresh": 31536000
},
"collections": {
"users": {
"schema": {
"username": {
"type": "string",
"unique": true
},
"password": {
"type": "hash"
},
"permissions": {
"type": "array",
"default": ["user"]
}
},
"permissions": {
"*": {
"post": true
},
"user": {
"get": {
"q": {
"_id": "$.auth._id"
},
"project": "-password"
},
"patch": {
"pick": ["username"],
"q": {
"_id": "$.auth._id"
},
"io": {
"$._id": ["_id"],
"admin": true
}
}
},
"admin": {
"get": true,
"post": {
"io": {
"$._id": ["_id"],
"admin": true
}
},
"patch": {
"io": {
"$._id": ["_id"],
"admin": true
}
},
"delete": {
"io": {
"$._id": ["_id"],
"admin": true
}
}
}
}
}
}
}
Customize the config.json file to fit your project's needs, then start the development server with the following command:
Be sure to change the secret and refreshsecret values before using in production.