
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@knovator/pagecreator-node
Advanced tools
Plug & Play functionality to Build dynamic pages on the fly.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
@knovator/pagecreator-node
is built with intent to build pages that are depend on backend data, and admin can change how page will look like.
To integrate @knovator/pagecreator-node
, you should be having basic nodejs application up and running with express (optionally using mongoose for mongodb database). @knovator/pagecreator-node
provides routes for widget
, page
and user
to use in application.
It's good start to have nodejs
application up and running with express
. Good to have used i18next to add message in response codes.
routes
uses mongoose
connection established by application, so it's required to connect to database before using package. For example,
// db.js
const mongoose = require('mongoose');
mongoose
.connect('mongodb://localhost:27017/knovator')
.then(() => console.info('Database connected'))
.catch((err) => {
console.error('DB Error', err);
});
module.exports = mongoose;
Image upload route for upload
& remove
is needed to declare externally. Example,
// fileRoute.js
const express = require('express');
const router = express.Router();
router.post(`/files/upload`, (req, res) => {
// TO DO: some file storage operation
let uri = '/image.jpg';
let id = '62c54b15524b6b59d2313c02';
res.json({
code: 'SUCCESS',
data: { id, uri },
message: 'File uploaded successfully',
});
});
router.delete(`/files/remove/:id`, (req, res) => {
// TO DO: some file remove operation
res.json({
code: 'SUCCESS',
data: {},
message: 'File removed successfully',
});
});
module.exports = router;
Sample App file
require('./src/db');
require('./src/models/file');
const cors = require('cors');
const express = require('express');
const fileRoutes = require('./fileRoute.js');
const PORT = 8080;
const app = express();
app.use(cors());
app.use(express.static('public'));
app.use(fileRoutes);
// ...
app.listen(PORT, () => {
console.log(`App started on ${PORT}`);
});
npm install @knovator/pagecreator-node
# or
yarn add @knovator/pagecreator-node
App/Main file is a good place to use @knovator/pagecreator-node
const {
setConfig,
WidgetRoutes,
ItemRoutes,
FileUploadRoute,
PageRoutes,
UserRoutes,
} = require('@knovator/pagecreator-node');
setConfig({
collections: [
{
title: 'Notifications',
collectionName: 'notifications',
filters: { isDeleted: false, isActive: true },
searchColumns: ['name', 'code'],
},
],
});
app.use('/widgets', WidgetRoutes);
app.use('/items', ItemRoutes);
app.use('/media', FileUploadRoute);
app.use('/pages', PageRoutes);
app.use('/users', UserRoutes);
app.listen(PORT, () => {
console.log(`App started on ${PORT}`);
});
Through setConfig
function e can set logger
, collections
and catchAsync
functions as parameters. By collections
, we can add reference of application collections.
handleUpdateData
is used to handle update redis cache when data is updated in database. It takes collectionName
and _id
as parameters.
import { handleUpdateData } from '@knovator/pagecreator-node';
handleUpdateData('notifications', '62c54b15524b6b59d2313c02');
logger
// default
console;
catchAsync
// default
function catchAsync(fn) {
return function (req, res, next) {
Promise.resolve(fn(req, res, next)).catch((err) => {
// this.logger.error(err.message);
res.status(internalServerError).json({
code: RESPONSE_CODE.ERROR,
message: err.message,
data: {},
});
});
};
}
collections
redis
redis://localhost:6379
or { HOST: 'localhost', PORT: 6379, PASSWORD: "test", USER: "test", DB: 0 }
Code | Description |
---|---|
title | Title of collection name to show in UI |
collectionName | Collection name specified in database |
filters | Filter object to apply while getting data, like { isDeleted: false, isActive: true } |
searchColumns | Array of fields to to perform search |
aggregations | Array of aggregation items you want to apply while retriving items |
customWidgetTypes | Array of widget types to add, like { label: "", value: "", imageOnly: true, collectionsOnly: true; } |
Example,
setConfig({
collections: [
{
title: 'Notifications',
collectionName: 'notifications',
filters: { isDeleted: false, isActive: true },
searchColumns: ['name', 'code'],
aggregations: [
{
$lookup: {
from: 'file',
let: {
id: '$fileId',
},
pipeline: [
{
$match: {
$expr: {
$eq: ['$_id', '$$id'],
},
},
},
{
$project: {
_id: 1,
nm: 1,
uri: 1,
mimeType: 1,
},
},
],
as: 'fileId',
}
},
{
$project: {
_id: 1,
nm: 1,
fileId: 1,
}
},
{
$match: {
deletedAt: { $exists: false },
}
}
]
},
],
});
Response follows following structure
{
code: RESPONSE_CODES,
message: "" // if internationalized is applied
data: {}
}
Code | Description |
---|---|
SUCCESS | When request fullfiled without error |
ERROR | When request fullfiled with error |
Message | Description |
---|---|
Widget with same code is available | When widget with same code is exist in database |
HTTP | Description |
---|---|
200 | When request fullfiled without error |
201 | When document is created |
500 | When internal server occurred |
422 | When Validation error occurred |
404 | When Resource is not found |
This are the routes that gets integrated by @knovator/pagecreator-node
,
Route | Method | Description |
---|---|---|
/widget-types | GET | Get widget-types like Image and provided collections |
/selection-types | GET | Get Selection types like Fixed Card and Carousel |
/list | POST | List widget data in pagination |
/ | POST | Create widget |
/:id | PUT | Update widget |
/:id | PATCH | Partial Update widget |
/:id | DELETE | Delete widget whose id send in body |
/collection-data | POST | Get collection data |
Route | Method | Description |
---|---|---|
/list | POST | List page data in pagination |
/ | POST | Create page |
/:id | PUT | Update page |
/:id | DELETE | Delete page whose id send in body |
Route | Method | Description |
---|---|---|
/widget-data | POST | Get widget-data data for specified widget code in body |
/page-data | POST | Get page-data data for specified page code in body |
descriptor
codes & i18n
code for messagesNextjs i18n package adds facility for internationalization in nodejs application, and it's used in following manner
// usage
req?.i18n?.(CODE);
CODE | Description |
---|---|
widget.getItemsTypes | While fetching widget types |
widget.getWidgetTypes | While fetching selection types |
widget.getAll | While fetching widgets |
widget.create | While creating widget |
widget.update | While updating widget |
widget.partialUpdate | While doing partialUpdate for widget, like toggle IsActive |
widget.delete | While deleting widget |
widget.getCollectionData | While getting widget collection-data |
page.getAll | While getting pages in pagination |
page.create | While creating page |
page.update | While updating page |
page.delete | While deleting page |
user.widgetNotFound | While widget is not found |
user.pageNotFound | While page is not found |
user.getWidgetData | While getting widget data |
user.getPageData | While getting page data |
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE.txt
for more information.
Knovator Technologies
Project Link: https://github.com/knovator/pagecreator
FAQs
PageCreator Node.js module
The npm package @knovator/pagecreator-node receives a total of 13 weekly downloads. As such, @knovator/pagecreator-node popularity was classified as not popular.
We found that @knovator/pagecreator-node demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.