Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Gosling is simple, plugin ready es6 node server similar to express.
import Gosling from 'gosling';
const app = new Gosling(1337);
app.listen();
app.use('/', () => (request, response, next) => {
response.write('Hello World!');
next();
});
HTTPS can be used out of the box with Gosling. Pass a node https options object to the constructor.
Note: HTTPS Options should either be the first or second argument, if second we assume Port is the first.
import { readFileSync } from 'fs';
import Gosling from 'gosling';
const httpsOptions = {
key: readFileSync('./ssl/key.pem'),
cert: readFileSync('./ssl/cert.pem')
};
const app = new Gosling(1337, httpsOptions);
app.listen();
Gosling ships with a router bundled, it can be accessed by importing separately
import Gosling, { Router } from 'gosling';
const app = new Gosling(1337);
const router = new Router();
app.listen();
router.use('/', () => (req, res, next) => {});
app.use('/api', router);
When assigning a path to router that router is then scoped to only process request that match the prefix.
Routers are completely recursive and can be nested deeply.
import { Router } from 'gosling';
const router = new Router();
const subrouter = new Router();
subrouter.get(/\/post\/[a-z0-9]+$/, bobsLawBlog);
router.use('/api/blog', subrouter);
export router;
Gosling's constructor takes the following optional arguments:
Once instantiated Gosling offers the following methods:
listen
Number
) - throws error if port is already assignedFunction
)close
Function
)port
use
(Universal request)
String
or RegExp
get
String
or RegExp
post
String
or RegExp
put
String
or RegExp
delete
String
or RegExp
The methods
(get
, post
, put
, delete
, use
) API takes two arguments and creates Request Objects…
- Path (as String or RegExp) [optional]
- Thunk (function returning function) [required]
- Note: All method calls are chainable app.use().get().post()
is valid.
Request Objects are the heart of Gosling's speed and simplicity. They can be hand coded or passed through the method
API reducer.
// Request Object
{
path: '/' /* String or RegExp */
method: /GET/i /* RegExp only */
thunk() {
/* some code */
return (request, response, next) => {
/* response or request modifications */
next();
}
}
}
You can use the simple API to produce Request Objects by:
app.use('<Path>', () => (req, res, next) => {});
app.get('<Path>', () => (req, res, next) => {});
app.post('<Path>', () => (req, res, next) => {});
app.put('<Path>', () => (req, res, next) => {});
app.delete('<Path>', () => (req, res, next) => {});
methods
API does the work of Method checking, so no need to pass that.use
method will try to run on every request.path
is passed in, the thunk is processed on all matching request methods.
app.use(() => (req, res, next) => {})
will be run on all requests.method
calls are chainable
app.use(() => {}).get(() => {}).post(() => {});
[3.0.0] - 2016-11-17
app.use('/', thunk, thunk, thunk)
index.js
is only the basic code, and utils.js
contains all of our additional functionsFAQs
Gosling is a simple es6 node server, similar to express.
The npm package gosling receives a total of 0 weekly downloads. As such, gosling popularity was classified as not popular.
We found that gosling demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.