Skip to content

Commit

Permalink
update dependencies (#96)
Browse files Browse the repository at this point in the history
* bump: npm dependency

* upgrade all npm dependency

* migrate aws-sdk to v3

* update firebase depericated sdk

* migrate eslint rules

* migrate husky

* update gitpod configurations

* fixup
  • Loading branch information
ramank775 authored Sep 30, 2024
1 parent 5672d3b commit 9faf9b9
Show file tree
Hide file tree
Showing 74 changed files with 3,940 additions and 4,490 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

41 changes: 0 additions & 41 deletions .eslintrc.json

This file was deleted.

10 changes: 7 additions & 3 deletions .gitpod/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
FROM gitpod/workspace-mongodb

ARG NATS_VERSION="v2.8.3"
ARG KAFKA_VERSION="3.2.0"
ARG NATS_CLI_VERSION="0.0.33"
ARG NODE_VERSION="20"
ARG NATS_VERSION="v2.10.21"
ARG KAFKA_VERSION="3.8.0"
ARG NATS_CLI_VERSION="0.1.5"

COPY .gitpod/load.nginx.conf /etc/nginx/nginx.conf

RUN bash -c 'source $HOME/.nvm/nvm.sh && nvm install $NODE_VERSION \
&& nvm use $NODE_VERSION && nvm alias default $NODE_VERSION'

RUN sudo apt-get update && sudo apt-get install redis-server -y

RUN wget https://downloads.apache.org/kafka/${KAFKA_VERSION}/kafka_2.13-${KAFKA_VERSION}.tgz && \
Expand Down
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"trailingComma": "es5",
"bracketSpacing": true
}
61 changes: 61 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
const babelParser = require('@babel/eslint-parser');
const eslintPluginPrettier = require('eslint-plugin-prettier');
const eslintPluginNode = require('eslint-plugin-node');
const eslintConfigPrettier = require('eslint-config-prettier');
const eslintStylisticJs = require('@stylistic/eslint-plugin-js');

module.exports = [
{
ignores: ['node_modules/**'],
},
{
languageOptions: {
parser: babelParser,
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
process: 'readonly',
__dirname: 'readonly',
module: 'readonly',
require: 'readonly',
},
parserOptions: {
requireConfigFile: false,
},
},
plugins: {
prettier: eslintPluginPrettier,
node: eslintPluginNode,
'@stylistic/js': eslintStylisticJs,
},
rules: {
'prettier/prettier': 'error',
'no-console': 'warn',
'consistent-return': 'off',
'no-process-exit': 'off',
'no-param-reassign': 'off',
'no-return-await': 'off',
'no-underscore-dangle': 'off',
'prefer-destructuring': [
'error',
{
object: true,
array: false,
},
],
'no-unused-vars': [
'error',
{
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
},
],
},
settings: {
node: {
tryExtensions: ['.js', '.json', '.node'],
},
},
},
eslintConfigPrettier,
];
4 changes: 2 additions & 2 deletions helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function extractInfoFromRequest(req, key = 'user', defaultValue = null) {

function getUTCTime() {
const now = new Date();
const utc = now.getTime() + (now.getTimezoneOffset() * 60 * 1000);
const utc = now.getTime() + now.getTimezoneOffset() * 60 * 1000;
return utc;
}

Expand Down Expand Up @@ -45,5 +45,5 @@ module.exports = {
shortuuid,
getFilename,
base64ToProtoBuffer,
schemas
schemas,
};
4 changes: 2 additions & 2 deletions helper/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module.exports = {
authHeaders: Joi.object({
user: Joi.string().required(),
accesskey: Joi.string().required(),
}).unknown(true)
}
}).unknown(true),
};
12 changes: 8 additions & 4 deletions libs/cache/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const { RedisCache } = require('./redis-cache');
function addMemCacheOptions(cmd) {
cmd = cmd
.option('--cache-type <cache-type>', 'Type of cache service (local, redis)', 'local')
.option('--redis-endpoint <redis-endpoint>', 'Redis endpoint to connet with in case of cache type redis', '127.0.0.1:6379')
.option(
'--redis-endpoint <redis-endpoint>',
'Redis endpoint to connet with in case of cache type redis',
'127.0.0.1:6379'
);
return cmd;
}

Expand All @@ -16,7 +20,7 @@ async function initMemCache(context) {
memCache = new LocalCache();
break;
case 'redis':
memCache = new RedisCache(context.options)
memCache = new RedisCache(context.options);
break;
default:
memCache = new LocalCache();
Expand All @@ -28,5 +32,5 @@ async function initMemCache(context) {

module.exports = {
addMemCacheOptions,
initMemCache
}
initMemCache,
};
6 changes: 3 additions & 3 deletions libs/cache/local-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class LocalCache {
}

async getAll(keys) {
const values = keys.map(key => values.push(this._cache[key]));
const values = keys.map((key) => values.push(this._cache[key]));
}

async set(key, value) {
Expand All @@ -19,5 +19,5 @@ class LocalCache {
}

module.exports = {
LocalCache
}
LocalCache,
};
13 changes: 6 additions & 7 deletions libs/cache/redis-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ class RedisCache {

/**
* Create redis cache instance
* @param {{redisEndpoint: string}} options
* @param {{redisEndpoint: string}} options
*/
constructor(options) {
this._redis = new Redis(options.redisEndpoint)
this._redis = new Redis(options.redisEndpoint);
}

async get(key) {
return await this._redis.get(key)
return await this._redis.get(key);
}

async getAll(keys) {
Expand All @@ -27,11 +27,10 @@ class RedisCache {
}

async del(key) {
await this._redis.del(key)
await this._redis.del(key);
}

}

module.exports = {
RedisCache
}
RedisCache,
};
15 changes: 9 additions & 6 deletions libs/discovery-service-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fs = require('fs')
const fs = require('fs');

class FileDiscoveryService {
_services = {};
Expand All @@ -8,17 +8,20 @@ class FileDiscoveryService {
* @params {{serviceDiscoveryPath: string}} options
*/
constructor(options) {
const file = fs.readFileSync(options.serviceDiscoveryPath)
this._services = JSON.parse(file)
const file = fs.readFileSync(options.serviceDiscoveryPath);
this._services = JSON.parse(file);
}

async getServiceUrl(srv) {
return this._services[srv]
return this._services[srv];
}
}

function addDiscoveryServiceOptions(cmd) {
cmd = cmd.option('--service-discovery-path <service-discovery-path>', 'Path to service discovery service')
cmd = cmd.option(
'--service-discovery-path <service-discovery-path>',
'Path to service discovery service'
);
return cmd;
}

Expand All @@ -31,4 +34,4 @@ async function initDiscoveryService(context) {
module.exports = {
addDiscoveryServiceOptions,
initDiscoveryService,
}
};
16 changes: 8 additions & 8 deletions libs/event-args/connection-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { getProtoDefination } = require('./util');
const CONNECTION_STATE = {
CONNECTED: 'CONNECTED',
DISCONNECTED: 'DISCONNECTED',
}
};

class ConnectionStateEvent extends IEventArg {
static #binary_resource_name = 'UserConnectionState';
Expand All @@ -31,17 +31,17 @@ class ConnectionStateEvent extends IEventArg {
const message = new ConnectionStateEvent();
message._user = user;
message._gateway = gateway;
message._state = CONNECTION_STATE.DISCONNECTED
message._state = CONNECTION_STATE.DISCONNECTED;
return message;
}

static fromBinary(payload) {
const messageDefination = getProtoDefination(ConnectionStateEvent.#binary_resource_name);
const incomming = messageDefination.decode(payload)
const incomming = messageDefination.decode(payload);
const json = messageDefination.toObject(incomming, {
longs: Long,
enums: String
})
enums: String,
});
const message = new ConnectionStateEvent();
message._user = json.user;
message._state = json.state;
Expand All @@ -54,7 +54,7 @@ class ConnectionStateEvent extends IEventArg {
const message = {
user: this._user,
gateway: this._gateway,
state: messageDefination.State[this._state]
state: messageDefination.State[this._state],
};
const temp = messageDefination.create(message);
return messageDefination.encode(temp).finish();
Expand All @@ -75,5 +75,5 @@ class ConnectionStateEvent extends IEventArg {

module.exports = {
CONNECTION_STATE,
ConnectionStateEvent
}
ConnectionStateEvent,
};
4 changes: 2 additions & 2 deletions libs/event-args/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ module.exports = {
CONNECTION_STATE,
ConnectionStateEvent,
LoginEvent,
loadProtoDefination
}
loadProtoDefination,
};
12 changes: 6 additions & 6 deletions libs/event-args/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LoginEvent extends IEventArg {
_messageVersion = 2.1;

constructor(args) {
super()
super();
this._user = args.user;
this._deviceId = args.deviceId;
this._notificationToken = args.notificationToken;
Expand All @@ -27,11 +27,11 @@ class LoginEvent extends IEventArg {

static fromBinary(payload) {
const messageDefination = getProtoDefination(LoginEvent.#binary_resource_name);
const incomming = messageDefination.decode(payload)
const incomming = messageDefination.decode(payload);
const json = messageDefination.toObject(incomming, {
longs: Long,
enums: String
})
enums: String,
});
const message = new LoginEvent(json);
return message;
}
Expand Down Expand Up @@ -66,5 +66,5 @@ class LoginEvent extends IEventArg {
}

module.exports = {
LoginEvent
}
LoginEvent,
};
Loading

0 comments on commit 9faf9b9

Please sign in to comment.