-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from neatht/v14.0.0/master
🚀 Version 14.0.0
- Loading branch information
Showing
102 changed files
with
4,292 additions
and
869 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Server settings | ||
NODE_ENV=development | ||
SERVER_PORT=5000 | ||
|
||
# Authentication settings | ||
EMAIL_KEY=https://example.com/email | ||
AUTH0_AUDIENCE= | ||
AUTH0_ISSUER= | ||
JWKS_URI= | ||
|
||
# SSL settings | ||
SSL_CRT_FILE=../server.cert | ||
SSL_KEY_FILE=../server.key | ||
|
||
# Database settings | ||
DB_ENDPOINT= | ||
DB_NAME= | ||
DB_USERNAME= | ||
DB_PASSWORD= | ||
|
||
# AWS | ||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
AWS_BUCKET_NAME= |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import CacheService from './service'; | ||
|
||
const profileTtl = 60 * 60 * 1; | ||
const ttl = 60 * 5 * 1; | ||
const ownProfileTtl = 60 * 168 * 1; | ||
export const profileCache = new CacheService(profileTtl, 'profileCache'); | ||
export const mediaCache = new CacheService(ttl, 'mediaCache'); | ||
export const projectCache = new CacheService(ttl, 'projectCache'); | ||
export const ownProfileCache = new CacheService(ownProfileTtl, 'ownProfileCache'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* Service to create cache storage for API endpoints */ | ||
import NodeCache from 'node-cache'; | ||
|
||
export default class CacheService { | ||
cache: NodeCache; | ||
name: string; | ||
|
||
constructor(ttlSec: number, name: string = 'Cache') { | ||
this.cache = new NodeCache({ stdTTL: ttlSec, checkperiod: ttlSec * 0.2, useClones: false }); | ||
this.name = name; | ||
} | ||
|
||
get(key: string, storeCallback: () => Promise<any>) { | ||
const value: any = this.cache.get(key); | ||
|
||
if (value) { | ||
console.log(`${this.name}: key ${key} exists in cache. Retrieving from cache...`) | ||
return Promise.resolve(value); | ||
} | ||
|
||
console.log(`${this.name}: key ${key} doesn't exist in cache. Accessing DB and storing in cache...`) | ||
|
||
return storeCallback().then(res => { | ||
this.cache.set(key, res); | ||
return res; | ||
}) | ||
} | ||
|
||
set(key: string, obj: any) { | ||
console.log(`${this.name}: key ${key} SET in cache`) | ||
this.cache.set(key, obj); | ||
} | ||
|
||
del(key: string) { | ||
console.log(`${this.name}: key ${key} DELETED from cache`) | ||
this.cache.del(key); | ||
} | ||
|
||
delStartsWith(startStr: string = '') { | ||
if (!startStr) { | ||
return; | ||
} | ||
|
||
const keys = this.cache.keys(); | ||
|
||
for (const key of keys) { | ||
if (key.indexOf(startStr) === 0) { | ||
this.del(key); | ||
} | ||
} | ||
} | ||
|
||
flush() { | ||
this.cache.flushAll(); | ||
} | ||
} |
Oops, something went wrong.