
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
norman-common-server
Advanced tools
##Importing core services
var commonServer = require('norman-common-server');
##Error Handling
##Logging
##Using the Common MongoDB Connection
###Initializing the connection This must be done once by the main server process. This is done by the Norman AppServer, you may do this manually in your service tests.
commonServer.db.connection.initialize({ database: "norman-test" }, function (err) {
if (err) {
console.error("Oops, no magic today!");
}
});
Optional second parameter allows configuring the deployment strategy. Default strategy "single" stores all Norman collection into a single database. Production strategy "distribute" spreads the collections over multiple domain databases to reduce write contention. Database distribution may be fine-tuned with the "map" strategy.
###Getting a mongoose connection The following code snippet returns a connection to the database configured for the module "my-module" according to the deployment strategy.
var connection = commonserver.db.connection.getMongooseConnection("my-module");
###Getting a Mongo database connection
var db1 = commonserver.db.connection.getDb("my-module");
var db2 = commonserver.db.connection.getMongooseConnection("my-other-module").db;
###Creating mongoose models We offer a simple way to define mongoose model on a specific connection :
var commonServer = require('norman-common-server'),
mongoose = commonServer.db.mongoose;
var MySchema = mongoose.createSchema('my-module', { ... });
module.exports = mongoose.createModel('MyModel', MySchema);
##Using the Service Registry
###Declaring a service
var commonServer = require('norman-common-server);
var fooService = {...};
commonServer.registry.registerModule(fooService, 'Foo');
###Accessing a service
var commonServer = require('norman-common-server);
var fooService = commonServer.registry.getModule('Foo');
##File Upload
You can configure the file upload in Norman/dist/server/config.json. You can add the section fileUpload which is not there by default (default value for parameters are then applied)
The following are the options that can be passed to File Upload.
The destination directory for the uploaded files.
"dest": "./uploads/"
An object specifying the size limits of the following optional properties. This object is passed to busboy directly, and the details of properties can be found on busboy's page
"limits": {
"fieldNameSize": 100,
"files": 2,
"fields": 5
}
Specifying the limits can help protect your site against denial of service (DoS) attacks.
A Boolean value to specify whether empty submitted values should be processed and applied to req.body; defaults to false;
"includeEmptyFields": true
If this Boolean value is true, the file.buffer property holds the data in-memory that Multer would have written to disk. The dest option is still populated and the path property contains the proposed path to save the file. Defaults to false.
"inMemory": true
WARNING: Uploading very large files, or relatively small files in large numbers very quickly, can cause your application to run out of memory when inMemory is set to true.
it's MIME type white list. The default value are:
If you want to override this list, set the mimetype parameter as below :
"mimetype": ["image/bmp", "application/zip", "application/octet-stream", "application/pdf"]
To implement scan actions after the upload (and prior to processing of the uploaded file on the server) you will need to set the 3 following parameters (baseSourceDir, baseTargetDir and action) :
baseSourceDir: Fully qualified path to a directory where the uploaded file will be moved for processing the scan actions.
baseTargetDir: Fully qualified path to a directory where the uploaded files will be moved after the scan actions. The BUILD server will assume that the uploaded file are safe (not infected by any virus) if :
action: Fully qualified path to a shell script that will be executed upon upload. Note: do not remove the parameters ${source_dir} ${target_dir} and ${files} that needs to be passed to your scan action shell script for processing : The BUILD server will set the input parameters as :
${source_dir} = baseSourceDir + ‘/’ + <a unique request GUID >
${target_dir} = baseTargetDir + ‘/’ + <a unique request GUID >
${files} = baseSourceDir + ‘/’ + <a unique request GUID > + ‘/’ + fileName1 + " " + baseSourceDir + ‘/’ + <a unique request GUID > + ‘/’ + fileName2 etc…
Note : It is the responsibility of the shell script to move the uploaded file to the target directory after correct processing (hence why the ${target_dir} is passed as an argument) For example
"fileUpload":{
"scan": {
"action" : "C:\\temp\\image\\scanTrue.bat ${source_dir} ${target_dir} ${files}",
"baseSourceDir" : "C:\\temp\\image\\",
"baseTargetDir": "C:\\temp\\image2\\",
}
}
Full sample FileUpload section:
"fileUpload":{
"scan": {
"action" : "C:\\temp\\Norman\\Action\\scanTrue.bat ${source_dir} ${target_dir} ${files}",
"baseSourceDir" : "C:\\temp\\Norman\\Source\\",
"baseTargetDir": "C:\\temp\\Norman\\Dest\\"
},
"limits": {
"fields": 4,
"fileSize": 0.5e7,
"files": 2,
"parts": 5
},
"dest": "C:\\temp\\Norman\\Upload\\",
"mimetype": ["image/bmp", "application/zip", "application/octet-stream", "application/pdf"]
}
FAQs
Norman common server components
We found that norman-common-server demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.