function insertTemplates() { const templates = [ { name: 'welcome', subject: 'Welcome to builderbook.org', message: `<%= userName %>, <p> At Builder Book, we are excited to help you build useful, production-ready web apps from scratch. </p> <p> See list of available books here. </p> Kelly & Timur, Team BB `, }, ]; templates.forEach(async (template) => { if ((await EmailTemplate.find({ name: template.name }).countDocuments()) > 0) { return; } EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); }); }); }
return Purchase.create({ userId: user._id, bookId: book._id,
request=http.request; run.create({ user:req.headers["user-doclever"], host:opt.host,
it('should report error when the refreshToken is expired', async () => { await RefreshToken.create(expiredRefreshToken); return request(app) .post('/v1/auth/refresh-token') .send({ email: dbUser.email, refreshToken: expiredRefreshToken.token }) .expect(httpStatus.UNAUTHORIZED) .then((res) => { expect(res.body.code).to.be.equal(401); expect(res.body.message).to.be.equal('Invalid refresh token.'); }); });
it('should return a new accessToken when refreshToken and email match', async () => { await RefreshToken.create(refreshToken); return request(app) .post('/v1/auth/refresh-token') .send({ email: dbUser.email, refreshToken: refreshToken.token }) .expect(httpStatus.OK) .then((res) => { expect(res.body).to.have.a.property('accessToken'); expect(res.body).to.have.a.property('refreshToken'); expect(res.body).to.have.a.property('expiresIn'); }); });
it("should report error when email and refreshToken don't match", async () => { await RefreshToken.create(refreshToken); return request(app) .post('/v1/auth/refresh-token') .send({ email: user.email, refreshToken: refreshToken.token }) .expect(httpStatus.UNAUTHORIZED) .then((res) => { const { code } = res.body; const { message } = res.body; expect(code).to.be.equal(401); expect(message).to.be.equal('Incorrect email or refreshToken'); }); });
function insertTemplates() { const templates = [ { name: 'welcome', subject: 'Welcome to builderbook.org', message: `<%= userName %>, <p> At Builder Book, we are excited to help you build useful, production-ready web apps from scratch. </p> <p> See list of available books here. </p> Kelly & Timur, Team BB `, }, ]; templates.forEach(async (template) => { if ((await EmailTemplate.find({ name: template.name }).countDocuments()) > 0) { return; } EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); }); }); }
function insertTemplates() { const templates = [ { name: 'welcome', subject: 'Welcome to builderbook.org', message: `<%= userName %>, <p> At Builder Book, we are excited to help you build useful, production-ready web apps from scratch. </p> <p> See list of available books here. </p> Kelly & Timur, Team BB `, }, ]; templates.forEach(async (template) => { if ((await EmailTemplate.find({ name: template.name }).countDocuments()) > 0) { return; } EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); }); }); }
function insertTemplates() { const templates = [ { name: 'welcome', subject: 'Welcome to builderbook.org', message: `<%= userName %>, <p> At Builder Book, we are excited to help you build useful, production-ready web apps from scratch. </p> <p> See list of available books here. </p> Kelly & Timur, Team BB `, }, ]; templates.forEach(async (template) => { if ((await EmailTemplate.find({ name: template.name }).countDocuments()) > 0) { return; } EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); }); }); }
function insertTemplates() { const templates = [ { name: 'welcome', subject: 'Welcome to builderbook.org', message: `<%= userName %>, <p> At Builder Book, we are excited to help you build useful, production-ready web apps from scratch. </p> <p> See list of available books here. </p> Kelly & Timur, Team BB `, }, ]; templates.forEach(async (template) => { if ((await EmailTemplate.find({ name: template.name }).countDocuments()) > 0) { return; } EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); }); }); }
function insertTemplates() { const templates = [ { name: 'welcome', subject: 'Welcome to builderbook.org', message: `<%= userName %>, <p> At Builder Book, we are excited to help you build useful, production-ready web apps from scratch. </p> <p> See list of available books here. </p> Kelly & Timur, Team BB `, }, ]; templates.forEach(async (template) => { if ((await EmailTemplate.find({ name: template.name }).countDocuments()) > 0) { return; } EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); }); }); }
function insertTemplates() { const templates = [ { name: 'welcome', subject: 'Welcome to builderbook.org', message: `<%= userName %>, <p> At Builder Book, we are excited to help you build useful, production-ready web apps from scratch. </p> <p> See list of available books here. </p> Kelly & Timur, Team BB `, }, ]; templates.forEach(async (template) => { if ((await EmailTemplate.find({ name: template.name }).countDocuments()) > 0) { return; } EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); }); }); }
return Purchase.create({ userId: user._id, bookId: book._id,
EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); });
EmailTemplate.create(template).catch((error) => { logger.error('EmailTemplate insertion error:', error); });