Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cokoapps/server
  • jgutix/server
2 results
Show changes
Commits on Source (2)
......@@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [1.12.0](https://gitlab.coko.foundation/cokoapps/server/compare/v1.11.0...v1.12.0) (2021-03-23)
### Features
* **server:** include send email component & update docs ([8dc9faa](https://gitlab.coko.foundation/cokoapps/server/commit/8dc9faae2f85bd462c3b4dbc90ad126a0a6584c6))
## [1.11.0](https://gitlab.coko.foundation/cokoapps/server/compare/v1.10.0...v1.11.0) (2021-03-18)
......
......@@ -8,7 +8,7 @@ Install package and remove the dependencies it is meant to replace.
```sh
## if migrating from an existing project
yarn remove pubsweet pubsweet-server @pubsweet/logger @pubsweet/base-model
yarn remove pubsweet pubsweet-server @pubsweet/logger @pubsweet/base-model @pubsweet/component-send-email
##
yarn add @coko/server
......@@ -155,6 +155,46 @@ cron.schedule('* * * * * *', () => {
The library that enables this is `node-cron`. Be sure to check its [documentation](https://github.com/node-cron/node-cron#node-cron) for further details.
### Queue manager
We use [`pg-boss`](https://github.com/timgit/pg-boss/blob/master/docs/usage.md#publish) to handle queues. This package exposes an instance of pg-boss, so you don't have to initiate it yourself. In other words, there's no need to use the `start` and `stop` functions. These are handled.
The following SQL code needs to have run on your database, either via a database init script or as part of a migration:
```sql
CREATE EXTENSION IF NOT EXISTS pgcrypto;
```
Use the queue manager as follows:
```js
const { boss } = require('@coko/server')
await boss.publish('my-job', { and: 'how' })
```
The above method is recommended, but if you already use pubsweet's `connectToJobQueue` and want a low-overhead way to switch to `@coko/server`, we also expose the same function for backwards compatibility.
```js
// Replace this
const { connectToJobQueue } = require('pubsweet-server')
// With this
const { connectToJobQueue } = require('@coko/server')
```
You can also disable the queue manager altogether with the following config option:
```js
// config/default.js
module.exports = {
'pubsweet-server': {
useJobQueue: false,
},
}
```
### Disable GraphQL
There are cases where you might not want a graphql server at all. eg. If you are building a sevice with a single REST api endpoint with coko server.
......@@ -213,6 +253,22 @@ Returns pubsweet's base model
const { BaseModel } = require('@coko/server')
```
##### sendEmail
Reads your mailer config and sends an email.
```js
const { sendEmail } = require('@coko/server')
sendEmail({
from: 'noreply@me.com',
html: `<p>Hello</p>`,
subject: `The hello message`,
text: 'Hello',
to: 'someone@email.com',
})
```
##### createJWT
`createJWT` is an export of a function in `pubsweet-server` that does just that.
......
{
"name": "@coko/server",
"version": "1.11.0",
"version": "1.12.0",
"description": "A tweaked version of pubsweet-server for use by Coko's projects",
"main": "src/index.js",
"scripts": {
......@@ -24,6 +24,7 @@
},
"dependencies": {
"@pubsweet/base-model": "^4.0.8",
"@pubsweet/component-send-email": "^0.4.11",
"@pubsweet/db-manager": "^3.1.19",
"@pubsweet/errors": "^2.0.44",
"@pubsweet/logger": "^0.2.54",
......
......@@ -5,6 +5,7 @@ const authentication = require('pubsweet-server/src/authentication')
const { pubsubManager, startServer } = require('pubsweet-server')
const logger = require('@pubsweet/logger')
const { db } = require('@pubsweet/db-manager')
const { send: sendEmail } = require('@pubsweet/component-send-email')
const app = require('./app')
const { boss, connectToJobQueue } = require('./pgboss')
......@@ -17,6 +18,8 @@ module.exports = {
pubsubManager,
startServer,
sendEmail,
BaseModel,
logger,
db,
......
......@@ -416,6 +416,13 @@
objection "^2.1.6"
uuid "^7.0.3"
"@pubsweet/component-send-email@^0.4.11":
version "0.4.11"
resolved "https://registry.yarnpkg.com/@pubsweet/component-send-email/-/component-send-email-0.4.11.tgz#9870da674881b5d13f2933ce30ef1925a011d3d3"
integrity sha512-IhKTxELx+dG2K77lcnnwg6bmm3TzhIUXtrDTvu/h+J3CNu/wfpMYowttBijVJxg69RLkA9dhBWIZEIay8TQIaw==
dependencies:
nodemailer "^6.4.18"
"@pubsweet/db-manager@^3.1.19":
version "3.1.19"
resolved "https://registry.yarnpkg.com/@pubsweet/db-manager/-/db-manager-3.1.19.tgz#0f54eea9640d66e2467d5211b8841f1b91dc107c"
......@@ -6003,6 +6010,11 @@ node-notifier@^5.4.0:
shellwords "^0.1.1"
which "^1.3.0"
nodemailer@^6.4.18:
version "6.5.0"
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.5.0.tgz#d12c28d8d48778918e25f1999d97910231b175d9"
integrity sha512-Tm4RPrrIZbnqDKAvX+/4M+zovEReiKlEXWDzG4iwtpL9X34MJY+D5LnQPH/+eghe8DLlAVshHAJZAZWBGhkguw==
normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.3.5:
version "2.5.0"
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"
......