Skip to content

Commit

Permalink
Replace uses of deprecated Buffer()
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Barlow committed Nov 30, 2020
1 parent 9e5d931 commit 37d0368
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion final/server/src/__tests__/resolvers.mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('[Mutation.login]', () => {

it('returns base64 encoded email as user token if successful', async () => {
const args = { email: '[email protected]' };
const base64Email = new Buffer(mockContext.user.email).toString('base64');
const base64Email = Buffer.from(mockContext.user.email).toString('base64');
findOrCreateUser.mockReturnValueOnce({ token: base64Email });

// check the resolver response
Expand Down
2 changes: 1 addition & 1 deletion final/server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const dataSources = () => ({
const context = async ({ req }) => {
// simple auth check on every request
const auth = (req.headers && req.headers.authorization) || '';
const email = new Buffer(auth, 'base64').toString('ascii');
const email = Buffer.from(auth, 'base64').toString('ascii');

// if the email isn't formatted validly, return null for user
if (!isEmail.validate(email)) return { user: null };
Expand Down
2 changes: 1 addition & 1 deletion final/server/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = {
login: async (_, { email }, { dataSources }) => {
const user = await dataSources.userAPI.findOrCreateUser({ email });
if (user) {
user.token = new Buffer(email).toString('base64');
user.token = Buffer.from(email).toString('base64');
return user;
}
},
Expand Down
2 changes: 1 addition & 1 deletion start/server/src/__tests__/resolvers.mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('[Mutation.login]', () => {
it('returns base64 encoded email if successful', async () => {
const args = { email: '[email protected]' };
findOrCreateUser.mockReturnValueOnce(true);
const base64Email = new Buffer(mockContext.user.email).toString('base64');
const base64Email = Buffer.from(mockContext.user.email).toString('base64');

// check the resolver response
const res = await resolvers.Mutation.login(null, args, mockContext);
Expand Down

0 comments on commit 37d0368

Please sign in to comment.