mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge pull request #5897 from Ocelot-Social-Community/node-16-image-upload
refactor(backend): node 19 with fixed image upload
This commit is contained in:
commit
05954ee04f
@ -1 +1 @@
|
||||
v12.19.0
|
||||
v19.4.0
|
||||
@ -1,7 +1,7 @@
|
||||
##################################################################################
|
||||
# BASE (Is pushed to DockerHub for rebranding) ###################################
|
||||
##################################################################################
|
||||
FROM node:12.19.0-alpine3.10 as base
|
||||
FROM node:19.4.0-alpine3.17 as base
|
||||
|
||||
# ENVs
|
||||
## DOCKER_WORKDIR would be a classical ARG, but that is not multi layer persistent - shame
|
||||
|
||||
@ -19,12 +19,19 @@ Wait a little until your backend is up and running at [http://localhost:4000/](h
|
||||
## Installation without Docker
|
||||
|
||||
For the local installation you need a recent version of
|
||||
[node](https://nodejs.org/en/) (>= `v10.12.0`). We are using
|
||||
`12.19.0` and therefore we recommend to use the same version
|
||||
[Node](https://nodejs.org/en/) (>= `v16.19.0`). We are using
|
||||
`v19.4.0` and therefore we recommend to use the same version
|
||||
([see](https://github.com/Ocelot-Social-Community/Ocelot-Social/issues/4082)
|
||||
some known problems with more recent node versions). You can use the
|
||||
[node version manager](https://github.com/nvm-sh/nvm) to switch
|
||||
between different local node versions.
|
||||
[node version manager](https://github.com/nvm-sh/nvm) `nvm` to switch
|
||||
between different local Node versions:
|
||||
|
||||
```bash
|
||||
# install Node
|
||||
$ cd backend
|
||||
$ nvm install v19.4.0
|
||||
$ nvm use v19.4.0
|
||||
```
|
||||
|
||||
Install node dependencies with [yarn](https://yarnpkg.com/en/):
|
||||
|
||||
@ -32,6 +39,10 @@ Install node dependencies with [yarn](https://yarnpkg.com/en/):
|
||||
# in main folder
|
||||
$ cd backend
|
||||
$ yarn install
|
||||
# or just
|
||||
$ yarn
|
||||
# or just later on to use version of ".nvmrc" file
|
||||
$ nvm use && yarn
|
||||
```
|
||||
|
||||
Copy Environment Variables:
|
||||
|
||||
@ -10,4 +10,5 @@ module.exports = {
|
||||
],
|
||||
coverageReporters: ['lcov', 'text'],
|
||||
testMatch: ['**/src/**/?(*.)+(spec|test).js?(x)'],
|
||||
setupFilesAfterEnv: ['<rootDir>/test/setup.js']
|
||||
}
|
||||
|
||||
@ -65,22 +65,22 @@
|
||||
"linkifyjs": "~2.1.8",
|
||||
"lodash": "~4.17.14",
|
||||
"merge-graphql-schemas": "^1.7.8",
|
||||
"metascraper": "^5.11.8",
|
||||
"metascraper-audio": "^5.14.26",
|
||||
"metascraper-author": "^5.14.22",
|
||||
"metascraper": "^5.33.5",
|
||||
"metascraper-audio": "^5.33.5",
|
||||
"metascraper-author": "^5.33.5",
|
||||
"metascraper-clearbit-logo": "^5.3.0",
|
||||
"metascraper-date": "^5.11.8",
|
||||
"metascraper-description": "^5.23.1",
|
||||
"metascraper-image": "^5.11.8",
|
||||
"metascraper-lang": "^5.23.1",
|
||||
"metascraper-date": "^5.33.5",
|
||||
"metascraper-description": "^5.33.5",
|
||||
"metascraper-image": "^5.33.5",
|
||||
"metascraper-lang": "^5.33.5",
|
||||
"metascraper-lang-detector": "^4.10.2",
|
||||
"metascraper-logo": "^5.14.26",
|
||||
"metascraper-publisher": "^5.23.0",
|
||||
"metascraper-soundcloud": "^5.23.0",
|
||||
"metascraper-title": "^5.11.8",
|
||||
"metascraper-url": "^5.14.26",
|
||||
"metascraper-video": "^5.11.8",
|
||||
"metascraper-youtube": "^5.23.0",
|
||||
"metascraper-logo": "^5.33.5",
|
||||
"metascraper-publisher": "^5.33.5",
|
||||
"metascraper-soundcloud": "^5.33.5",
|
||||
"metascraper-title": "^5.33.5",
|
||||
"metascraper-url": "^5.33.5",
|
||||
"metascraper-video": "^5.33.5",
|
||||
"metascraper-youtube": "^5.33.5",
|
||||
"migrate": "^1.7.0",
|
||||
"mime-types": "^2.1.26",
|
||||
"minimatch": "^3.0.4",
|
||||
@ -123,6 +123,8 @@
|
||||
"supertest": "~4.0.2"
|
||||
},
|
||||
"resolutions": {
|
||||
"fs-capacitor": "6.0.0"
|
||||
"**/**/fs-capacitor":"^6.2.0",
|
||||
"**/graphql-upload": "^11.0.0",
|
||||
"nan": "2.17.0"
|
||||
}
|
||||
}
|
||||
|
||||
7
backend/src/schema/resolvers/Upload.js
Normal file
7
backend/src/schema/resolvers/Upload.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { GraphQLUpload } from 'graphql-upload'
|
||||
|
||||
export default {
|
||||
// This maps the `Upload` scalar to the implementation provided
|
||||
// by the `graphql-upload` package.
|
||||
Upload: GraphQLUpload,
|
||||
}
|
||||
@ -96,7 +96,7 @@ describe('Query', () => {
|
||||
description: null,
|
||||
html: null,
|
||||
image: null,
|
||||
lang: null,
|
||||
lang: 'false',
|
||||
publisher: null,
|
||||
sources: ['resource'],
|
||||
title: null,
|
||||
|
||||
@ -113,10 +113,11 @@ const sanitizeRelationshipType = (relationshipType) => {
|
||||
const localFileUpload = ({ createReadStream, uniqueFilename }) => {
|
||||
const destination = `/uploads/${uniqueFilename}`
|
||||
return new Promise((resolve, reject) =>
|
||||
createReadStream()
|
||||
.pipe(createWriteStream(`public${destination}`))
|
||||
.on('finish', () => resolve(destination))
|
||||
.on('error', reject),
|
||||
createReadStream().pipe(
|
||||
createWriteStream(`public${destination}`)
|
||||
.on('finish', () => resolve(destination))
|
||||
.on('error', (error) => reject(error)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import { RedisPubSub } from 'graphql-redis-subscriptions'
|
||||
import { PubSub } from 'graphql-subscriptions'
|
||||
import Redis from 'ioredis'
|
||||
import bodyParser from 'body-parser'
|
||||
import { graphqlUploadExpress } from 'graphql-upload'
|
||||
|
||||
export const NOTIFICATION_ADDED = 'NOTIFICATION_ADDED'
|
||||
const { REDIS_DOMAIN, REDIS_PORT, REDIS_PASSWORD } = CONFIG
|
||||
@ -67,6 +68,7 @@ const createServer = (options) => {
|
||||
},
|
||||
},
|
||||
debug: !!CONFIG.DEBUG,
|
||||
uploads: false,
|
||||
tracing: !!CONFIG.DEBUG,
|
||||
formatError: (error) => {
|
||||
if (error.message === 'ERROR_VALIDATION') {
|
||||
@ -85,6 +87,7 @@ const createServer = (options) => {
|
||||
app.use(express.static('public'))
|
||||
app.use(bodyParser.json({ limit: '10mb' }))
|
||||
app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }))
|
||||
app.use(graphqlUploadExpress())
|
||||
server.applyMiddleware({ app, path: '/' })
|
||||
const httpServer = http.createServer(app)
|
||||
server.installSubscriptionHandlers(httpServer)
|
||||
|
||||
8
backend/test/setup.js
Normal file
8
backend/test/setup.js
Normal file
@ -0,0 +1,8 @@
|
||||
// Polyfill missing encoders in jsdom
|
||||
// https://stackoverflow.com/questions/68468203/why-am-i-getting-textencoder-is-not-defined-in-jest
|
||||
import { TextEncoder, TextDecoder } from 'util'
|
||||
global.TextEncoder = TextEncoder
|
||||
global.TextDecoder = TextDecoder
|
||||
|
||||
// Metascraper takes longer nowadays, double time
|
||||
jest.setTimeout(10000)
|
||||
1336
backend/yarn.lock
1336
backend/yarn.lock
File diff suppressed because it is too large
Load Diff
@ -4,18 +4,32 @@
|
||||
|
||||
## Installation
|
||||
|
||||
For preparation we need Node and recommend to use [node version manager](https://github.com/nvm-sh/nvm) `nvm` to switch
|
||||
between different local Node versions:
|
||||
|
||||
```bash
|
||||
# install Node
|
||||
$ cd webapp
|
||||
$ nvm install v16.19.0
|
||||
$ nvm use v16.19.0
|
||||
```
|
||||
|
||||
Install node dependencies with [yarn](https://yarnpkg.com/en/):
|
||||
|
||||
```bash
|
||||
# install all dependencies
|
||||
$ cd webapp/
|
||||
$ cd webapp
|
||||
$ yarn install
|
||||
# or just
|
||||
$ yarn
|
||||
# or just later on to use version of ".nvmrc" file
|
||||
$ nvm use && yarn
|
||||
```
|
||||
|
||||
Copy:
|
||||
|
||||
```text
|
||||
# in webapp/
|
||||
# in webapp
|
||||
cp .env.template .env
|
||||
```
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user