Skip to content

Commit

Permalink
Merge branch 'feat/v6' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbo2002 committed Oct 19, 2023
2 parents c2f40a3 + af0ae98 commit 740a901
Show file tree
Hide file tree
Showing 24 changed files with 976 additions and 964 deletions.
34 changes: 14 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ to generate subscriptionable calendar feeds.
<br />
<br />

## ⚠️ Migration to v6
In version 6 some breaking changes were made to make `ical-generator` even better. A short list of
these breaking changes and how you can adapt your code can be found in our
[Migration Guide](https://github.com/sebbo2002/ical-generator/wiki/Migration-Guide:-v5-%E2%86%92-v6).

## 📦 Installation

npm install ical-generator

# For TypeScript Users
# (see "I use Typescript and get TS2307: Cannot find module errors" section below)
npm i -D @types/node rrule moment-timezone moment dayjs @types/luxon


## ⚡️ Quick Start

Expand All @@ -53,10 +54,16 @@ calendar.createEvent({
url: 'http://sebbo.net/'
});

http.createServer((req, res) => calendar.serve(res))
.listen(3000, '127.0.0.1', () => {
console.log('Server running at http://127.0.0.1:3000/');
http.createServer((req, res) => {
res.writeHead(200, {
'Content-Type': 'text/calendar; charset=utf-8',
'Content-Disposition': 'attachment; filename="calendar.ics"'
});

res.end(calendar.toString());
}).listen(3000, '127.0.0.1', () => {
console.log('Server running at http://127.0.0.1:3000/');
});
```
See the [examples](./examples) folder for more examples.

Expand Down Expand Up @@ -114,19 +121,6 @@ npm run browser-test

## 🙋 FAQ

### What's `Error: Can't resolve 'fs'`?
`ical-generator` uses the node.js `fs` module to save your calendar on the filesystem. In browser environments, you usually don't need this, so if you pass `null` for fs in your bundler. In webpack this looks like this:

```json
{
"resolve": {
"fallback": {
"fs": false
}
}
}
```

### Where's the changelog?
It's [here](https://github.com/sebbo2002/ical-generator/blob/develop/CHANGELOG.md). If you need the changelog for
`ical-generator` 1.x.x and older, you'll find it [here](https://github.com/sebbo2002/ical-generator/blob/25338b8bf98f9afd3c88849e735fa33fa45fb766/CHANGELOG.md).
Expand Down
7 changes: 6 additions & 1 deletion examples/example-express.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ const cal = ical({
const app = express();

app.get('/calendar', (req, res) => {
cal.serve(res);
res.writeHead(200, {
'Content-Type': 'text/calendar; charset=utf-8',
'Content-Disposition': 'attachment; filename="calendar.ics"'
});

res.end(cal.toString());
});

app.listen(3000);
7 changes: 6 additions & 1 deletion examples/example-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ const cal = ical({
});

http.createServer(function (req, res) {
cal.serve(res);
res.writeHead(200, {
'Content-Type': 'text/calendar; charset=utf-8',
'Content-Disposition': 'attachment; filename="calendar.ics"'
});

res.end(cal.toString());
}).listen(3000, '127.0.0.1', function () {
console.log('Server running at http://127.0.0.1:3000/');
});
10 changes: 7 additions & 3 deletions examples/example-koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ const cal = ical({
const app = new Koa();

app.use(ctx => {
ctx.status = 200; // Koa defaults to 404 when it sees that status is unset
ctx.respond = false; // mark request as handled for Koa
cal.serve(ctx.res);
ctx.status = 200;
ctx.respond = false;

ctx.set('Content-Type', 'text/calendar; charset=utf-8');
ctx.set('Content-Disposition', 'attachment; filename="calendar.ics"');

ctx.body = cal.toString();
});

app.listen(3000);
7 changes: 6 additions & 1 deletion examples/example-micro.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ const cal = ical({

// start with $ micro example/example-micro.js
module.exports = (req, res) => {
cal.serve(res);
res.writeHead(200, {
'Content-Type': 'text/calendar; charset=utf-8',
'Content-Disposition': 'attachment; filename="calendar.ics"'
});

res.end(cal.toString());
};


9 changes: 8 additions & 1 deletion examples/example-quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ calendar.createEvent({
url: 'http://sebbo.net/'
});

http.createServer((req, res) => calendar.serve(res))
http.createServer((req, res) => {
res.writeHead(200, {
'Content-Type': 'text/calendar; charset=utf-8',
'Content-Disposition': 'attachment; filename="calendar.ics"'
});

res.end(calendar.toString());
})
.listen(3000, '127.0.0.1', () => {
console.log('Server running at http://127.0.0.1:3000/');
});
66 changes: 0 additions & 66 deletions package-lock.json

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

6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"author": "Sebastian Pekarek <[email protected]>",
"browser": {
"fs": false
},
"bugs": {
"url": "http://github.com/sebbo2002/ical-generator/issues"
},
Expand All @@ -19,7 +16,6 @@
"@touch4it/ical-timezones": "^1.9.0",
"@types/luxon": "^3.3.2",
"@types/mocha": "^10.0.2",
"@types/node": "^20.6.3",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"c8": "^8.0.1",
Expand All @@ -34,7 +30,6 @@
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"nyc": "^15.1.0",
"portfinder": "^1.0.32",
"rrule": "^2.7.2",
"semantic-release": "^22.0.5",
"semantic-release-license": "^1.0.2",
Expand Down Expand Up @@ -77,7 +72,6 @@
"@touch4it/ical-timezones": ">=1.6.0",
"@types/luxon": ">= 1.26.0",
"@types/mocha": ">= 8.2.1",
"@types/node": ">= 15.0.0",
"dayjs": ">= 1.10.0",
"luxon": ">= 1.26.0",
"moment": ">= 2.29.0",
Expand Down
Loading

0 comments on commit 740a901

Please sign in to comment.