import { cache } from '@sage/toolkit';
const myCache: LocalCache = cache.createLocalCache({
name: 'users',
stdTTL: 60
});
// set data
await myCache.set('123', 'cde');
// Get data
const data = await myCache.get('123');
import { httpClient } from '@sage/toolkit';
const hc = httpClient.create({timeout: 5000}, 'Amelia');
const { data } = await hc.get('/api/v2/campaings/1234');
import { mySqlClient } from '@sage/toolkit';
sqlClient: MySqlClient = mySqlClient.create({
host: config.get('connections.mysql.host'),
port: config.get('connections.mysql.port'),
user: config.get('connections.mysql.user'),
password: config.get('connections.mysql.password'),
database: config.get('connections.mysql.schema')
});
const query = 'SELECT * FROM obus_user WHERE obus_id = ?';
const { results } = await this.sqlClient.query(query, [123]);
import { ldapMiddleware } from '@sage/toolkit';
...
this.app.use('/api', ldapMiddleware());npx @sage/generator create
[16:57:07] Starting 'obnode:default'...
? What is the name of your project? SageIsAwesome
? What is the description?
? What is the version of your project? 1.0.0
? What is the owner name? frontendguild
? What is your project type? Typescript + webpack (recommended)
? Continue? Yes
Running npm install, please wait...
***************************************
_
/(|
( :
__\ \ _____
(____) `|
(____)| |
(____).__|
(___)__.|_____
Congrats, your service is ready!
Now run it:
$ npm run build && npm start
And browse to:
http://localhost:7100/sageisawesome/api/welcome
Or
http://localhost:7100/sageisawesome/static
***************************************
[16:57:53] Finished 'obnode:default' after 46 s
[slush] Scaffolding doneimport { cache } from '@sage/toolkit';
const myCache: Memcached = cache.createMemcachedClient({
name: 'campaigns-cache',
memcacheCluster: 'memcached-amplify'
});
// set data
await myCache.set('2423424534', JSON.stringify(campaign));
// Get data
const data = await myCache.get('2423424534');