@Module({
controllers: [AppController],
providers: [
Test1Service,
{
provide: 'BLOG',
useValue: new Test2Service('blog'),
},
{
provide: 'ANALYTICS',
useValue: new Test2Service('analytics'),
}
],
})
export class AppModule {}
@Injectable()
export class Test1Service {
constructor(
@Inject('BLOG') public testBlog: Test2Service,
@Inject('ANALYTICS') public testAnalytics: Test2Service
) {}
getIndex() {
this.testBlog.getIndex()
this.testAnalytics.getIndex()
}
}
const query = getConnection()
.createQueryBuilder()
.select('title')
.addSelect(qb => qb
.select('name')
.from(AuthorsEntity, 'aut')
.leftJoin(ArticlesEntity, 'art1', 'aut.id = art1.author_id')
.where('art1.id = art.id'),
'name'
)
.from(ArticlesEntity, 'art');
return query.getRawMany();
@Column({
type: 'date',
name: 'time'
})
time: string;
/**
* Force date types (TIMESTAMP, DATETIME, DATE) to be returned as strings rather then inflated into JavaScript Date objects.
* Can be true/false or an array of type names to keep as strings.
*/
readonly dateStrings?: boolean | string[];
require('dotenv').config();
const express = require('express');
const request = require('supertest');
const bodyParser = require('body-parser');
const redisMock = require('redis-mock');
const redis = require('redis');
const auth = require('../../../../server/controllers/auth');
const { i18next, i18nextMiddleware } = require('../../../i18n-server');
jest.spyOn(redis, 'createClient').mockImplementation(redisMock.createClient);
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(i18nextMiddleware);
app.post(
'/',
(req, res, next) => {
if (req.body.id && req.body.type) {
req.user = {
id: req.body.id,
type: req.body.type
};
}
next();
},
auth.signOut
);
describe('signOut', () => {
it('success', done => {
i18next.on('initialized', () => {
request(app)
.post('/')
.set('Accept-Language', 'en')
.type('application/x-www-form-urlencoded')
.send({
id: 1,
type: 'manager'
})
.end((err, res) => {
if (err) return done(err);
expect(res.status).toBe(200);
expect(res.body.result).toBe('ok');
done();
});
});
});
afterAll(() => {
redis.closeInstance();
});
});