Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
paygron-core
Advanced tools
A library that allows initializing all the necessary tools to build projects with ease.
npm i paygron-core
This library requires node-config
and js-yaml
, so both should be listed as dependencies in the package.json file.
To initialize the project, a YAML configuration file is needed in which the rules for initializing connectors, workers, and APIs will be defined.
Basic configuration
appName: myApp
env: local
Connectors will be initialized upon detecting the following configuration:
connectorA:
default:
connection:
url: myservice://127.0.0.1/exampleA
serverA:
connection:
url: another-url
serverB:
connection:
url: another-example
options:
optionA: valueA
optionB: valueB
optionN: ...
connectorB:
default:
connection:
url: myservice://127.0.0.1/exampleB
As seen above, you can specify multiple connections for each connector. The supported connectors are as follows: mysql
, mongodb
, rabbitmq
, and redis
Connectors share the following nesting structure: connectorA.*.connection
, where connectorA.default.connection
will be the default connector if no particular connector is specified when initializing the library.
You can register multiple cronjobs directly in the cronjobs.handlers
array. Each cronjob requires the following attributes:
Attribute | Required | Default | Description |
---|---|---|---|
handler | ✔ | Name of the module that will be searched in src/cronjobs | |
enabled | ✔ | false | Define whether the cronjob should be registered. By default, it will not be registered |
schedule | ✔ | Schedule expression. See more here | |
params | ✖ | {} | Object that will be injected into the cronjob. Useful for passing configurations. |
Example:
cronjobs:
handlers:
- handler: myFirstCron
enabled: true
schedule: '* * * * *' # every minute
params:
any: param
will: be pass
to: this handler
Required configuration:
api:
protocol: http
host: 127.0.0.1
port: 8080
The routes must be loaded at initialization time in the following way:
// index.ts
import core from 'paygron-core'
import config from 'config'
import routes from './routes'
const setup = async() => {
const app = core( config )
await app({ api: { routes } })
}
setup()
// routes.ts
import { RouteGroup, Deps, Context } from 'paygron-core'
const routes: RouteGroup = {
prefix: 'api',
namespace: 'users',
modules: [
{
version: '1',
module: 'create',
command: 'user',
middlewares: [],
method: 'POST',
handler: ( deps: Deps ) => async( ctx: Context ) => {
ctx.body = { 'Hello': 'World' }
},
},
],
}
export default [ routes ]
node: 18.13.0
npm: 8.19.3
git clone git@github.com:paygron/core.git;
cd core;
nvm i && npm i;
npm run test
npm run coverage
FAQs
Paygron Core
We found that paygron-core 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.