Skip to content

Commit

Permalink
Updated dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonjoh committed Apr 19, 2021
1 parent 2187ec5 commit 53281a6
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 121 deletions.
2 changes: 1 addition & 1 deletion demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

To run the completed project in this folder, you need the following:

- [Node.js](https://nodejs.org) installed on your development machine. If you do not have Node.js, visit the previous link for download options. (**Note:** This tutorial was written with Node version 12.6.1. The steps in this guide may work with other versions, but that has not been tested.)
- [Node.js](https://nodejs.org) installed on your development machine. If you do not have Node.js, visit the previous link for download options. (**Note:** This tutorial was written with Node version 14.15.0. The steps in this guide may work with other versions, but that has not been tested.)
- Either a personal Microsoft account with a mailbox on Outlook.com, or a Microsoft work or school account.

If you don't have a Microsoft account, there are a couple of options to get a free account:
Expand Down
8 changes: 5 additions & 3 deletions demo/graph-tutorial/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ app.set('view engine', 'hbs');

// <FormatDateSnippet>
var hbs = require('hbs');
var moment = require('moment');
var parseISO = require('date-fns/parseISO');
var formatDate = require('date-fns/format');
// Helper to format date/time sent by Graph
hbs.registerHelper('eventDateTime', function(dateTime){
return moment(dateTime).format('M/D/YY h:mm A');
hbs.registerHelper('eventDateTime', function(dateTime) {
const date = parseISO(dateTime);
return formatDate(date, 'M/d/yy h:mm a');
});
// </FormatDateSnippet>

Expand Down
158 changes: 73 additions & 85 deletions demo/graph-tutorial/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions demo/graph-tutorial/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@
"start": "node ./bin/www"
},
"dependencies": {
"@azure/msal-node": "^1.0.0-beta.0",
"@microsoft/microsoft-graph-client": "^2.1.1",
"@azure/msal-node": "^1.0.2",
"@microsoft/microsoft-graph-client": "^2.2.1",
"connect-flash": "^0.1.1",
"cookie-parser": "~1.4.4",
"debug": "^4.2.0",
"date-fns": "^2.21.1",
"date-fns-tz": "^1.1.4",
"debug": "^4.3.1",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-promise-router": "^4.0.1",
"express-promise-router": "^4.1.0",
"express-session": "^1.17.1",
"express-validator": "^6.6.1",
"hbs": "^4.1.1",
"express-validator": "^6.10.0",
"hbs": "^4.1.2",
"http-errors": "^1.8.0",
"isomorphic-fetch": "^3.0.0",
"moment": "^2.29.1",
"moment-timezone": "^0.5.31",
"morgan": "^1.10.0",
"uuid": "^8.3.1",
"windows-iana": "^4.2.1"
"windows-iana": "^5.0.1"
}
}
18 changes: 10 additions & 8 deletions demo/graph-tutorial/routes/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

const router = require('express-promise-router')();
const graph = require('../graph.js');
const moment = require('moment-timezone');
const addDays = require('date-fns/addDays');
const formatISO = require('date-fns/formatISO');
const startOfWeek = require('date-fns/startOfWeek');
const zonedTimeToUtc = require('date-fns-tz/zonedTimeToUtc');
const iana = require('windows-iana');
const { body, validationResult } = require('express-validator');
const validator = require('validator');
Expand All @@ -24,17 +27,16 @@ router.get('/',
const user = req.app.locals.users[req.session.userId];
// Convert user's Windows time zone ("Pacific Standard Time")
// to IANA format ("America/Los_Angeles")
// Moment needs IANA format
const timeZoneId = iana.findOneIana(user.timeZone);
const timeZoneId = iana.findIana(user.timeZone)[0];
console.log(`Time zone: ${timeZoneId.valueOf()}`);

// Calculate the start and end of the current week
// Get midnight on the start of the current week in the user's timezone,
// but in UTC. For example, for Pacific Standard Time, the time value would be
// 07:00:00Z
var startOfWeek = moment.tz(timeZoneId.valueOf()).startOf('week').utc();
var endOfWeek = moment(startOfWeek).add(7, 'day');
console.log(`Start: ${startOfWeek.format()}`);
var weekStart = zonedTimeToUtc(startOfWeek(new Date()), timeZoneId.valueOf());
var weekEnd = addDays(weekStart, 7);
console.log(`Start: ${formatISO(weekStart)}`);

// Get the access token
var accessToken;
Expand All @@ -53,8 +55,8 @@ router.get('/',
// Get the events
const events = await graph.getCalendarView(
accessToken,
startOfWeek.format(),
endOfWeek.format(),
formatISO(weekStart),
formatISO(weekEnd),
user.timeZone);

params.events = events.value;
Expand Down
2 changes: 1 addition & 1 deletion tutorial/01-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You should also have either a personal Microsoft account with a mailbox on Outlo
- You can [sign up for the Office 365 Developer Program](https://developer.microsoft.com/office/dev-program) to get a free Office 365 subscription.

> [!NOTE]
> This tutorial was written with Node version 12.18.4. The steps in this guide may work with other versions, but that has not been tested.
> This tutorial was written with Node version 14.15.0. The steps in this guide may work with other versions, but that has not been tested.
## Feedback

Expand Down
Loading

0 comments on commit 53281a6

Please sign in to comment.