Showing
24 changed files
with
896 additions
and
12 deletions
.gitignore
0 → 100644
1 | +.env | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
.idea/LINEBOT.iml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<module type="WEB_MODULE" version="4"> | ||
3 | + <component name="NewModuleRootManager"> | ||
4 | + <content url="file://$MODULE_DIR$"> | ||
5 | + <excludeFolder url="file://$MODULE_DIR$/.tmp" /> | ||
6 | + <excludeFolder url="file://$MODULE_DIR$/temp" /> | ||
7 | + <excludeFolder url="file://$MODULE_DIR$/tmp" /> | ||
8 | + </content> | ||
9 | + <orderEntry type="inheritedJdk" /> | ||
10 | + <orderEntry type="sourceFolder" forTests="false" /> | ||
11 | + </component> | ||
12 | +</module> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
.idea/misc.xml
0 → 100644
.idea/modules.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project version="4"> | ||
3 | + <component name="ProjectModuleManager"> | ||
4 | + <modules> | ||
5 | + <module fileurl="file://$PROJECT_DIR$/.idea/LINEBOT.iml" filepath="$PROJECT_DIR$/.idea/LINEBOT.iml" /> | ||
6 | + </modules> | ||
7 | + </component> | ||
8 | +</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
.idea/vcs.xml
0 → 100644
.idea/workspace.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project version="4"> | ||
3 | + <component name="ChangeListManager"> | ||
4 | + <list default="true" id="5c08ae96-2f87-46c1-b81d-f30e494ce252" name="Default Changelist" comment=""> | ||
5 | + <change beforePath="$PROJECT_DIR$/2018-12-04.docx" beforeDir="false" /> | ||
6 | + <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" /> | ||
7 | + <change beforePath="$PROJECT_DIR$/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/app.js" afterDir="false" /> | ||
8 | + <change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" /> | ||
9 | + <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" /> | ||
10 | + <change beforePath="$PROJECT_DIR$/발표자료.pptx" beforeDir="false" /> | ||
11 | + </list> | ||
12 | + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> | ||
13 | + <option name="SHOW_DIALOG" value="false" /> | ||
14 | + <option name="HIGHLIGHT_CONFLICTS" value="true" /> | ||
15 | + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | ||
16 | + <option name="LAST_RESOLUTION" value="IGNORE" /> | ||
17 | + </component> | ||
18 | + <component name="Git.Settings"> | ||
19 | + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> | ||
20 | + </component> | ||
21 | + <component name="ProjectId" id="1Th3ZaCWaOXH7anC3KM0Cp8NWrd" /> | ||
22 | + <component name="PropertiesComponent"> | ||
23 | + <property name="WebServerToolWindowFactoryState" value="false" /> | ||
24 | + <property name="last_opened_file_path" value="$PROJECT_DIR$" /> | ||
25 | + </component> | ||
26 | + <component name="RunDashboard"> | ||
27 | + <option name="ruleStates"> | ||
28 | + <list> | ||
29 | + <RuleState> | ||
30 | + <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> | ||
31 | + </RuleState> | ||
32 | + <RuleState> | ||
33 | + <option name="name" value="StatusDashboardGroupingRule" /> | ||
34 | + </RuleState> | ||
35 | + </list> | ||
36 | + </option> | ||
37 | + </component> | ||
38 | + <component name="SvnConfiguration"> | ||
39 | + <configuration /> | ||
40 | + </component> | ||
41 | + <component name="TaskManager"> | ||
42 | + <task active="true" id="Default" summary="Default task"> | ||
43 | + <changelist id="5c08ae96-2f87-46c1-b81d-f30e494ce252" name="Default Changelist" comment="" /> | ||
44 | + <created>1573898555947</created> | ||
45 | + <option name="number" value="Default" /> | ||
46 | + <option name="presentableId" value="Default" /> | ||
47 | + <updated>1573898555947</updated> | ||
48 | + <workItem from="1573898557106" duration="89000" /> | ||
49 | + </task> | ||
50 | + <servers /> | ||
51 | + </component> | ||
52 | + <component name="TypeScriptGeneratedFilesManager"> | ||
53 | + <option name="version" value="1" /> | ||
54 | + </component> | ||
55 | + <component name="Vcs.Log.Tabs.Properties"> | ||
56 | + <option name="TAB_STATES"> | ||
57 | + <map> | ||
58 | + <entry key="MAIN"> | ||
59 | + <value> | ||
60 | + <State /> | ||
61 | + </value> | ||
62 | + </entry> | ||
63 | + </map> | ||
64 | + </option> | ||
65 | + </component> | ||
66 | +</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
2018-12-04.docx
deleted
100644 → 0
No preview for this file type
README.md
deleted
100644 → 0
1 | +require("dotenv").config({path : '.env'}); | ||
2 | + | ||
1 | var express = require('express'); | 3 | var express = require('express'); |
2 | var app = express(); | 4 | var app = express(); |
3 | const line = require('@line/bot-sdk'); | 5 | const line = require('@line/bot-sdk'); |
... | @@ -14,12 +16,11 @@ var languagedetect_api_url = 'https://openapi.naver.com/v1/papago/detectLangs' | ... | @@ -14,12 +16,11 @@ var languagedetect_api_url = 'https://openapi.naver.com/v1/papago/detectLangs' |
14 | 16 | ||
15 | // Naver Auth Key | 17 | // Naver Auth Key |
16 | //새로 발급받은 naver papago api id, pw 입력 | 18 | //새로 발급받은 naver papago api id, pw 입력 |
17 | -var client_id = 'xZMx34y7uru1v8lywZ2d'; | 19 | +var client_id = process.env.client_id; |
18 | -var client_secret = 'p6L7M7WsH9'; | 20 | +var client_secret = process.env.client_secret; |
19 | - | ||
20 | const config = { | 21 | const config = { |
21 | - channelAccessToken: 'mnny0MJSezgBXzR9C3Ddcc1Csdb7Y9jkvy2nqV5saOmvR2YOJ1/kj/2M0CNsLA+57B2qDpdUQ7WbCTtIKx/LAJ6Kwfop4tX3up7EM8H9EZK1td6GMbhhCb6wvUFVdb1PcTO4joCv8mspd3ubo8a+gAdB04t89/1O/w1cDnyilFU=', | 22 | + channelAccessToken: process.env.channelAccessToken, |
22 | - channelSecret: 'bde77633a16fc5bfbd532d5990c6170e', | 23 | + channelSecret: process.env.channelSecret, |
23 | }; | 24 | }; |
24 | 25 | ||
25 | 26 | ||
... | @@ -108,6 +109,6 @@ function handleEvent(event) { | ... | @@ -108,6 +109,6 @@ function handleEvent(event) { |
108 | }); | 109 | }); |
109 | } | 110 | } |
110 | 111 | ||
111 | -app.listen(3000, function () { | 112 | +app.listen(80, function () { |
112 | - console.log('Linebot listening on port 3000!'); | 113 | + console.log('Linebot listening on port 80!'); |
113 | }); | 114 | }); | ... | ... |
node_modules/dotenv/CHANGELOG.md
0 → 100644
1 | +# Changelog | ||
2 | + | ||
3 | +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
4 | + | ||
5 | +## [8.2.0](https://github.com/motdotla/dotenv/compare/v8.1.0...v8.2.0) (2019-10-16) | ||
6 | + | ||
7 | +## [8.1.0](https://github.com/motdotla/dotenv/compare/v7.0.0...v8.1.0) (2019-08-18) | ||
8 | + | ||
9 | + | ||
10 | +### ⚠ BREAKING CHANGES | ||
11 | + | ||
12 | +* dropping Node v6 support because end-of-life | ||
13 | + | ||
14 | +* Drop support for Node v6 (#392) ([2e9636a](https://github.com/motdotla/dotenv/commit/2e9636a)), closes [#392](https://github.com/motdotla/dotenv/issues/392) | ||
15 | + | ||
16 | +# [8.0.0](https://github.com/motdotla/dotenv/compare/v7.0.0...v8.0.0) (2019-05-02) | ||
17 | + | ||
18 | +- Drop support for Node v6 (#392) ([2e9636a](https://github.com/motdotla/dotenv/commit/2e9636a)), closes [#392](https://github.com/motdotla/dotenv/issues/392) | ||
19 | + | ||
20 | +### BREAKING CHANGES | ||
21 | + | ||
22 | +- dropping Node v6 support because end-of-life | ||
23 | + | ||
24 | +## [7.0.0] - 2019-03-12 | ||
25 | + | ||
26 | +### Fixed | ||
27 | + | ||
28 | +- Fix removing unbalanced quotes ([#376](https://github.com/motdotla/dotenv/pull/376)) | ||
29 | + | ||
30 | +### Removed | ||
31 | + | ||
32 | +- Removed `load` alias for `config` for consistency throughout code and documentation. | ||
33 | + | ||
34 | +## [6.2.0] - 2018-12-03 | ||
35 | + | ||
36 | +### Added | ||
37 | + | ||
38 | +- Support preload configuration via environment variables ([#351](https://github.com/motdotla/dotenv/issues/351)) | ||
39 | + | ||
40 | +## [6.1.0] - 2018-10-08 | ||
41 | + | ||
42 | +### Added | ||
43 | + | ||
44 | +- `debug` option for `config` and `parse` methods will turn on logging | ||
45 | + | ||
46 | +## [6.0.0] - 2018-06-02 | ||
47 | + | ||
48 | +### Changed | ||
49 | + | ||
50 | +- _Breaking:_ drop support for Node v4 ([#304](https://github.com/motdotla/dotenv/pull/304)) | ||
51 | + | ||
52 | +## [5.0.0] - 2018-01-29 | ||
53 | + | ||
54 | +### Added | ||
55 | + | ||
56 | +- Testing against Node v8 and v9 | ||
57 | +- Documentation on trim behavior of values | ||
58 | +- Documentation on how to use with `import` | ||
59 | + | ||
60 | +### Changed | ||
61 | + | ||
62 | +- _Breaking_: default `path` is now `path.resolve(process.cwd(), '.env')` | ||
63 | +- _Breaking_: does not write over keys already in `process.env` if the key has a falsy value | ||
64 | +- using `const` and `let` instead of `var` | ||
65 | + | ||
66 | +### Removed | ||
67 | + | ||
68 | +- Testing against Node v7 | ||
69 | + | ||
70 | +## [4.0.0] - 2016-12-23 | ||
71 | + | ||
72 | +### Changed | ||
73 | + | ||
74 | +- Return Object with parsed content or error instead of false ([#165](https://github.com/motdotla/dotenv/pull/165)). | ||
75 | + | ||
76 | +### Removed | ||
77 | + | ||
78 | +- `verbose` option removed in favor of returning result. | ||
79 | + | ||
80 | +## [3.0.0] - 2016-12-20 | ||
81 | + | ||
82 | +### Added | ||
83 | + | ||
84 | +- `verbose` option will log any error messages. Off by default. | ||
85 | +- parses email addresses correctly | ||
86 | +- allow importing config method directly in ES6 | ||
87 | + | ||
88 | +### Changed | ||
89 | + | ||
90 | +- Suppress error messages by default ([#154](https://github.com/motdotla/dotenv/pull/154)) | ||
91 | +- Ignoring more files for NPM to make package download smaller | ||
92 | + | ||
93 | +### Fixed | ||
94 | + | ||
95 | +- False positive test due to case-sensitive variable ([#124](https://github.com/motdotla/dotenv/pull/124)) | ||
96 | + | ||
97 | +### Removed | ||
98 | + | ||
99 | +- `silent` option removed in favor of `verbose` | ||
100 | + | ||
101 | +## [2.0.0] - 2016-01-20 | ||
102 | + | ||
103 | +### Added | ||
104 | + | ||
105 | +- CHANGELOG to ["make it easier for users and contributors to see precisely what notable changes have been made between each release"](http://keepachangelog.com/). Linked to from README | ||
106 | +- LICENSE to be more explicit about what was defined in `package.json`. Linked to from README | ||
107 | +- Testing nodejs v4 on travis-ci | ||
108 | +- added examples of how to use dotenv in different ways | ||
109 | +- return parsed object on success rather than boolean true | ||
110 | + | ||
111 | +### Changed | ||
112 | + | ||
113 | +- README has shorter description not referencing ruby gem since we don't have or want feature parity | ||
114 | + | ||
115 | +### Removed | ||
116 | + | ||
117 | +- Variable expansion and escaping so environment variables are encouraged to be fully orthogonal | ||
118 | + | ||
119 | +## [1.2.0] - 2015-06-20 | ||
120 | + | ||
121 | +### Added | ||
122 | + | ||
123 | +- Preload hook to require dotenv without including it in your code | ||
124 | + | ||
125 | +### Changed | ||
126 | + | ||
127 | +- clarified license to be "BSD-2-Clause" in `package.json` | ||
128 | + | ||
129 | +### Fixed | ||
130 | + | ||
131 | +- retain spaces in string vars | ||
132 | + | ||
133 | +## [1.1.0] - 2015-03-31 | ||
134 | + | ||
135 | +### Added | ||
136 | + | ||
137 | +- Silent option to silence `console.log` when `.env` missing | ||
138 | + | ||
139 | +## [1.0.0] - 2015-03-13 | ||
140 | + | ||
141 | +### Removed | ||
142 | + | ||
143 | +- support for multiple `.env` files. should always use one `.env` file for the current environment | ||
144 | + | ||
145 | +[7.0.0]: https://github.com/motdotla/dotenv/compare/v6.2.0...v7.0.0 | ||
146 | +[6.2.0]: https://github.com/motdotla/dotenv/compare/v6.1.0...v6.2.0 | ||
147 | +[6.1.0]: https://github.com/motdotla/dotenv/compare/v6.0.0...v6.1.0 | ||
148 | +[6.0.0]: https://github.com/motdotla/dotenv/compare/v5.0.0...v6.0.0 | ||
149 | +[5.0.0]: https://github.com/motdotla/dotenv/compare/v4.0.0...v5.0.0 | ||
150 | +[4.0.0]: https://github.com/motdotla/dotenv/compare/v3.0.0...v4.0.0 | ||
151 | +[3.0.0]: https://github.com/motdotla/dotenv/compare/v2.0.0...v3.0.0 | ||
152 | +[2.0.0]: https://github.com/motdotla/dotenv/compare/v1.2.0...v2.0.0 | ||
153 | +[1.2.0]: https://github.com/motdotla/dotenv/compare/v1.1.0...v1.2.0 | ||
154 | +[1.1.0]: https://github.com/motdotla/dotenv/compare/v1.0.0...v1.1.0 | ||
155 | +[1.0.0]: https://github.com/motdotla/dotenv/compare/v0.4.0...v1.0.0 |
node_modules/dotenv/LICENSE
0 → 100644
1 | +Copyright (c) 2015, Scott Motte | ||
2 | +All rights reserved. | ||
3 | + | ||
4 | +Redistribution and use in source and binary forms, with or without | ||
5 | +modification, are permitted provided that the following conditions are met: | ||
6 | + | ||
7 | +* Redistributions of source code must retain the above copyright notice, this | ||
8 | + list of conditions and the following disclaimer. | ||
9 | + | ||
10 | +* Redistributions in binary form must reproduce the above copyright notice, | ||
11 | + this list of conditions and the following disclaimer in the documentation | ||
12 | + and/or other materials provided with the distribution. | ||
13 | + | ||
14 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
15 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
16 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
17 | +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
18 | +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
19 | +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
20 | +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
21 | +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
22 | +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
23 | +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
node_modules/dotenv/README.md
0 → 100644
1 | +# dotenv | ||
2 | + | ||
3 | +<img src="https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.png" alt="dotenv" align="right" /> | ||
4 | + | ||
5 | +Dotenv is a zero-dependency module that loads environment variables from a `.env` file into [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env). Storing configuration in the environment separate from code is based on [The Twelve-Factor App](http://12factor.net/config) methodology. | ||
6 | + | ||
7 | +[![BuildStatus](https://img.shields.io/travis/motdotla/dotenv/master.svg?style=flat-square)](https://travis-ci.org/motdotla/dotenv) | ||
8 | +[![Build status](https://ci.appveyor.com/api/projects/status/github/motdotla/dotenv?svg=true)](https://ci.appveyor.com/project/motdotla/dotenv/branch/master) | ||
9 | +[![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv) | ||
10 | +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) | ||
11 | +[![Coverage Status](https://img.shields.io/coveralls/motdotla/dotenv/master.svg?style=flat-square)](https://coveralls.io/github/motdotla/dotenv?branch=coverall-intergration) | ||
12 | +[![LICENSE](https://img.shields.io/github/license/motdotla/dotenv.svg)](LICENSE) | ||
13 | +[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) | ||
14 | + | ||
15 | +## Install | ||
16 | + | ||
17 | +```bash | ||
18 | +# with npm | ||
19 | +npm install dotenv | ||
20 | + | ||
21 | +# or with Yarn | ||
22 | +yarn add dotenv | ||
23 | +``` | ||
24 | + | ||
25 | +## Usage | ||
26 | + | ||
27 | +As early as possible in your application, require and configure dotenv. | ||
28 | + | ||
29 | +```javascript | ||
30 | +require('dotenv').config() | ||
31 | +``` | ||
32 | + | ||
33 | +Create a `.env` file in the root directory of your project. Add | ||
34 | +environment-specific variables on new lines in the form of `NAME=VALUE`. | ||
35 | +For example: | ||
36 | + | ||
37 | +```dosini | ||
38 | +DB_HOST=localhost | ||
39 | +DB_USER=root | ||
40 | +DB_PASS=s1mpl3 | ||
41 | +``` | ||
42 | + | ||
43 | +`process.env` now has the keys and values you defined in your `.env` file. | ||
44 | + | ||
45 | +```javascript | ||
46 | +const db = require('db') | ||
47 | +db.connect({ | ||
48 | + host: process.env.DB_HOST, | ||
49 | + username: process.env.DB_USER, | ||
50 | + password: process.env.DB_PASS | ||
51 | +}) | ||
52 | +``` | ||
53 | + | ||
54 | +### Preload | ||
55 | + | ||
56 | +You can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#cli_r_require_module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code. This is the preferred approach when using `import` instead of `require`. | ||
57 | + | ||
58 | +```bash | ||
59 | +$ node -r dotenv/config your_script.js | ||
60 | +``` | ||
61 | + | ||
62 | +The configuration options below are supported as command line arguments in the format `dotenv_config_<option>=value` | ||
63 | + | ||
64 | +```bash | ||
65 | +$ node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/your/env/vars | ||
66 | +``` | ||
67 | + | ||
68 | +Additionally, you can use environment variables to set configuration options. Command line arguments will precede these. | ||
69 | + | ||
70 | +```bash | ||
71 | +$ DOTENV_CONFIG_<OPTION>=value node -r dotenv/config your_script.js | ||
72 | +``` | ||
73 | + | ||
74 | +```bash | ||
75 | +$ DOTENV_CONFIG_ENCODING=latin1 node -r dotenv/config your_script.js dotenv_config_path=/custom/path/to/.env | ||
76 | +``` | ||
77 | + | ||
78 | +## Config | ||
79 | + | ||
80 | +`config` will read your `.env` file, parse the contents, assign it to | ||
81 | +[`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env), | ||
82 | +and return an Object with a `parsed` key containing the loaded content or an `error` key if it failed. | ||
83 | + | ||
84 | +```js | ||
85 | +const result = dotenv.config() | ||
86 | + | ||
87 | +if (result.error) { | ||
88 | + throw result.error | ||
89 | +} | ||
90 | + | ||
91 | +console.log(result.parsed) | ||
92 | +``` | ||
93 | + | ||
94 | +You can additionally, pass options to `config`. | ||
95 | + | ||
96 | +### Options | ||
97 | + | ||
98 | +#### Path | ||
99 | + | ||
100 | +Default: `path.resolve(process.cwd(), '.env')` | ||
101 | + | ||
102 | +You may specify a custom path if your file containing environment variables is located elsewhere. | ||
103 | + | ||
104 | +```js | ||
105 | +require('dotenv').config({ path: '/full/custom/path/to/your/env/vars' }) | ||
106 | +``` | ||
107 | + | ||
108 | +#### Encoding | ||
109 | + | ||
110 | +Default: `utf8` | ||
111 | + | ||
112 | +You may specify the encoding of your file containing environment variables. | ||
113 | + | ||
114 | +```js | ||
115 | +require('dotenv').config({ encoding: 'latin1' }) | ||
116 | +``` | ||
117 | + | ||
118 | +#### Debug | ||
119 | + | ||
120 | +Default: `false` | ||
121 | + | ||
122 | +You may turn on logging to help debug why certain keys or values are not being set as you expect. | ||
123 | + | ||
124 | +```js | ||
125 | +require('dotenv').config({ debug: process.env.DEBUG }) | ||
126 | +``` | ||
127 | + | ||
128 | +## Parse | ||
129 | + | ||
130 | +The engine which parses the contents of your file containing environment | ||
131 | +variables is available to use. It accepts a String or Buffer and will return | ||
132 | +an Object with the parsed keys and values. | ||
133 | + | ||
134 | +```js | ||
135 | +const dotenv = require('dotenv') | ||
136 | +const buf = Buffer.from('BASIC=basic') | ||
137 | +const config = dotenv.parse(buf) // will return an object | ||
138 | +console.log(typeof config, config) // object { BASIC : 'basic' } | ||
139 | +``` | ||
140 | + | ||
141 | +### Options | ||
142 | + | ||
143 | +#### Debug | ||
144 | + | ||
145 | +Default: `false` | ||
146 | + | ||
147 | +You may turn on logging to help debug why certain keys or values are not being set as you expect. | ||
148 | + | ||
149 | +```js | ||
150 | +const dotenv = require('dotenv') | ||
151 | +const buf = Buffer.from('hello world') | ||
152 | +const opt = { debug: true } | ||
153 | +const config = dotenv.parse(buf, opt) | ||
154 | +// expect a debug message because the buffer is not in KEY=VAL form | ||
155 | +``` | ||
156 | + | ||
157 | +### Rules | ||
158 | + | ||
159 | +The parsing engine currently supports the following rules: | ||
160 | + | ||
161 | +- `BASIC=basic` becomes `{BASIC: 'basic'}` | ||
162 | +- empty lines are skipped | ||
163 | +- lines beginning with `#` are treated as comments | ||
164 | +- empty values become empty strings (`EMPTY=` becomes `{EMPTY: ''}`) | ||
165 | +- inner quotes are maintained (think JSON) (`JSON={"foo": "bar"}` becomes `{JSON:"{\"foo\": \"bar\"}"`) | ||
166 | +- whitespace is removed from both ends of unquoted values (see more on [`trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)) (`FOO= some value ` becomes `{FOO: 'some value'}`) | ||
167 | +- single and double quoted values are escaped (`SINGLE_QUOTE='quoted'` becomes `{SINGLE_QUOTE: "quoted"}`) | ||
168 | +- single and double quoted values maintain whitespace from both ends (`FOO=" some value "` becomes `{FOO: ' some value '}`) | ||
169 | +- double quoted values expand new lines (`MULTILINE="new\nline"` becomes | ||
170 | + | ||
171 | +``` | ||
172 | +{MULTILINE: 'new | ||
173 | +line'} | ||
174 | +``` | ||
175 | + | ||
176 | +## FAQ | ||
177 | + | ||
178 | +### Should I commit my `.env` file? | ||
179 | + | ||
180 | +No. We **strongly** recommend against committing your `.env` file to version | ||
181 | +control. It should only include environment-specific values such as database | ||
182 | +passwords or API keys. Your production database should have a different | ||
183 | +password than your development database. | ||
184 | + | ||
185 | +### Should I have multiple `.env` files? | ||
186 | + | ||
187 | +No. We **strongly** recommend against having a "main" `.env` file and an "environment" `.env` file like `.env.test`. Your config should vary between deploys, and you should not be sharing values between environments. | ||
188 | + | ||
189 | +> In a twelve-factor app, env vars are granular controls, each fully orthogonal to other env vars. They are never grouped together as “environments”, but instead are independently managed for each deploy. This is a model that scales up smoothly as the app naturally expands into more deploys over its lifetime. | ||
190 | +> | ||
191 | +> – [The Twelve-Factor App](http://12factor.net/config) | ||
192 | + | ||
193 | +### What happens to environment variables that were already set? | ||
194 | + | ||
195 | +We will never modify any environment variables that have already been set. In particular, if there is a variable in your `.env` file which collides with one that already exists in your environment, then that variable will be skipped. This behavior allows you to override all `.env` configurations with a machine-specific environment, although it is not recommended. | ||
196 | + | ||
197 | +If you want to override `process.env` you can do something like this: | ||
198 | + | ||
199 | +```javascript | ||
200 | +const fs = require('fs') | ||
201 | +const dotenv = require('dotenv') | ||
202 | +const envConfig = dotenv.parse(fs.readFileSync('.env.override')) | ||
203 | +for (const k in envConfig) { | ||
204 | + process.env[k] = envConfig[k] | ||
205 | +} | ||
206 | +``` | ||
207 | + | ||
208 | +### Can I customize/write plugins for dotenv? | ||
209 | + | ||
210 | +For `dotenv@2.x.x`: Yes. `dotenv.config()` now returns an object representing | ||
211 | +the parsed `.env` file. This gives you everything you need to continue | ||
212 | +setting values on `process.env`. For example: | ||
213 | + | ||
214 | +```js | ||
215 | +const dotenv = require('dotenv') | ||
216 | +const variableExpansion = require('dotenv-expand') | ||
217 | +const myEnv = dotenv.config() | ||
218 | +variableExpansion(myEnv) | ||
219 | +``` | ||
220 | + | ||
221 | +### What about variable expansion? | ||
222 | + | ||
223 | +Try [dotenv-expand](https://github.com/motdotla/dotenv-expand) | ||
224 | + | ||
225 | +### How do I use dotenv with `import`? | ||
226 | + | ||
227 | +ES2015 and beyond offers modules that allow you to `export` any top-level `function`, `class`, `var`, `let`, or `const`. | ||
228 | + | ||
229 | +> When you run a module containing an `import` declaration, the modules it imports are loaded first, then each module body is executed in a depth-first traversal of the dependency graph, avoiding cycles by skipping anything already executed. | ||
230 | +> | ||
231 | +> – [ES6 In Depth: Modules](https://hacks.mozilla.org/2015/08/es6-in-depth-modules/) | ||
232 | + | ||
233 | +You must run `dotenv.config()` before referencing any environment variables. Here's an example of problematic code: | ||
234 | + | ||
235 | +`errorReporter.js`: | ||
236 | + | ||
237 | +```js | ||
238 | +import { Client } from 'best-error-reporting-service' | ||
239 | + | ||
240 | +export const client = new Client(process.env.BEST_API_KEY) | ||
241 | +``` | ||
242 | + | ||
243 | +`index.js`: | ||
244 | + | ||
245 | +```js | ||
246 | +import dotenv from 'dotenv' | ||
247 | +import errorReporter from './errorReporter' | ||
248 | + | ||
249 | +dotenv.config() | ||
250 | +errorReporter.client.report(new Error('faq example')) | ||
251 | +``` | ||
252 | + | ||
253 | +`client` will not be configured correctly because it was constructed before `dotenv.config()` was executed. There are (at least) 3 ways to make this work. | ||
254 | + | ||
255 | +1. Preload dotenv: `node --require dotenv/config index.js` (_Note: you do not need to `import` dotenv with this approach_) | ||
256 | +2. Import `dotenv/config` instead of `dotenv` (_Note: you do not need to call `dotenv.config()` and must pass options via the command line or environment variables with this approach_) | ||
257 | +3. Create a separate file that will execute `config` first as outlined in [this comment on #133](https://github.com/motdotla/dotenv/issues/133#issuecomment-255298822) | ||
258 | + | ||
259 | +## Contributing Guide | ||
260 | + | ||
261 | +See [CONTRIBUTING.md](CONTRIBUTING.md) | ||
262 | + | ||
263 | +## Change Log | ||
264 | + | ||
265 | +See [CHANGELOG.md](CHANGELOG.md) | ||
266 | + | ||
267 | +## Who's using dotenv? | ||
268 | + | ||
269 | +[These npm modules depend on it.](https://www.npmjs.com/browse/depended/dotenv) | ||
270 | + | ||
271 | +Projects that expand it often use the [keyword "dotenv" on npm](https://www.npmjs.com/search?q=keywords:dotenv). |
node_modules/dotenv/config.js
0 → 100644
node_modules/dotenv/lib/cli-options.js
0 → 100644
1 | +/* @flow */ | ||
2 | + | ||
3 | +const re = /^dotenv_config_(encoding|path|debug)=(.+)$/ | ||
4 | + | ||
5 | +module.exports = function optionMatcher (args /*: Array<string> */) { | ||
6 | + return args.reduce(function (acc, cur) { | ||
7 | + const matches = cur.match(re) | ||
8 | + if (matches) { | ||
9 | + acc[matches[1]] = matches[2] | ||
10 | + } | ||
11 | + return acc | ||
12 | + }, {}) | ||
13 | +} |
node_modules/dotenv/lib/env-options.js
0 → 100644
1 | +/* @flow */ | ||
2 | + | ||
3 | +// ../config.js accepts options via environment variables | ||
4 | +const options = {} | ||
5 | + | ||
6 | +if (process.env.DOTENV_CONFIG_ENCODING != null) { | ||
7 | + options.encoding = process.env.DOTENV_CONFIG_ENCODING | ||
8 | +} | ||
9 | + | ||
10 | +if (process.env.DOTENV_CONFIG_PATH != null) { | ||
11 | + options.path = process.env.DOTENV_CONFIG_PATH | ||
12 | +} | ||
13 | + | ||
14 | +if (process.env.DOTENV_CONFIG_DEBUG != null) { | ||
15 | + options.debug = process.env.DOTENV_CONFIG_DEBUG | ||
16 | +} | ||
17 | + | ||
18 | +module.exports = options |
node_modules/dotenv/lib/main.js
0 → 100644
1 | +/* @flow */ | ||
2 | +/*:: | ||
3 | + | ||
4 | +type DotenvParseOptions = { | ||
5 | + debug?: boolean | ||
6 | +} | ||
7 | + | ||
8 | +// keys and values from src | ||
9 | +type DotenvParseOutput = { [string]: string } | ||
10 | + | ||
11 | +type DotenvConfigOptions = { | ||
12 | + path?: string, // path to .env file | ||
13 | + encoding?: string, // encoding of .env file | ||
14 | + debug?: string // turn on logging for debugging purposes | ||
15 | +} | ||
16 | + | ||
17 | +type DotenvConfigOutput = { | ||
18 | + parsed?: DotenvParseOutput, | ||
19 | + error?: Error | ||
20 | +} | ||
21 | + | ||
22 | +*/ | ||
23 | + | ||
24 | +const fs = require('fs') | ||
25 | +const path = require('path') | ||
26 | + | ||
27 | +function log (message /*: string */) { | ||
28 | + console.log(`[dotenv][DEBUG] ${message}`) | ||
29 | +} | ||
30 | + | ||
31 | +const NEWLINE = '\n' | ||
32 | +const RE_INI_KEY_VAL = /^\s*([\w.-]+)\s*=\s*(.*)?\s*$/ | ||
33 | +const RE_NEWLINES = /\\n/g | ||
34 | +const NEWLINES_MATCH = /\n|\r|\r\n/ | ||
35 | + | ||
36 | +// Parses src into an Object | ||
37 | +function parse (src /*: string | Buffer */, options /*: ?DotenvParseOptions */) /*: DotenvParseOutput */ { | ||
38 | + const debug = Boolean(options && options.debug) | ||
39 | + const obj = {} | ||
40 | + | ||
41 | + // convert Buffers before splitting into lines and processing | ||
42 | + src.toString().split(NEWLINES_MATCH).forEach(function (line, idx) { | ||
43 | + // matching "KEY' and 'VAL' in 'KEY=VAL' | ||
44 | + const keyValueArr = line.match(RE_INI_KEY_VAL) | ||
45 | + // matched? | ||
46 | + if (keyValueArr != null) { | ||
47 | + const key = keyValueArr[1] | ||
48 | + // default undefined or missing values to empty string | ||
49 | + let val = (keyValueArr[2] || '') | ||
50 | + const end = val.length - 1 | ||
51 | + const isDoubleQuoted = val[0] === '"' && val[end] === '"' | ||
52 | + const isSingleQuoted = val[0] === "'" && val[end] === "'" | ||
53 | + | ||
54 | + // if single or double quoted, remove quotes | ||
55 | + if (isSingleQuoted || isDoubleQuoted) { | ||
56 | + val = val.substring(1, end) | ||
57 | + | ||
58 | + // if double quoted, expand newlines | ||
59 | + if (isDoubleQuoted) { | ||
60 | + val = val.replace(RE_NEWLINES, NEWLINE) | ||
61 | + } | ||
62 | + } else { | ||
63 | + // remove surrounding whitespace | ||
64 | + val = val.trim() | ||
65 | + } | ||
66 | + | ||
67 | + obj[key] = val | ||
68 | + } else if (debug) { | ||
69 | + log(`did not match key and value when parsing line ${idx + 1}: ${line}`) | ||
70 | + } | ||
71 | + }) | ||
72 | + | ||
73 | + return obj | ||
74 | +} | ||
75 | + | ||
76 | +// Populates process.env from .env file | ||
77 | +function config (options /*: ?DotenvConfigOptions */) /*: DotenvConfigOutput */ { | ||
78 | + let dotenvPath = path.resolve(process.cwd(), '.env') | ||
79 | + let encoding /*: string */ = 'utf8' | ||
80 | + let debug = false | ||
81 | + | ||
82 | + if (options) { | ||
83 | + if (options.path != null) { | ||
84 | + dotenvPath = options.path | ||
85 | + } | ||
86 | + if (options.encoding != null) { | ||
87 | + encoding = options.encoding | ||
88 | + } | ||
89 | + if (options.debug != null) { | ||
90 | + debug = true | ||
91 | + } | ||
92 | + } | ||
93 | + | ||
94 | + try { | ||
95 | + // specifying an encoding returns a string instead of a buffer | ||
96 | + const parsed = parse(fs.readFileSync(dotenvPath, { encoding }), { debug }) | ||
97 | + | ||
98 | + Object.keys(parsed).forEach(function (key) { | ||
99 | + if (!Object.prototype.hasOwnProperty.call(process.env, key)) { | ||
100 | + process.env[key] = parsed[key] | ||
101 | + } else if (debug) { | ||
102 | + log(`"${key}" is already defined in \`process.env\` and will not be overwritten`) | ||
103 | + } | ||
104 | + }) | ||
105 | + | ||
106 | + return { parsed } | ||
107 | + } catch (e) { | ||
108 | + return { error: e } | ||
109 | + } | ||
110 | +} | ||
111 | + | ||
112 | +module.exports.config = config | ||
113 | +module.exports.parse = parse |
node_modules/dotenv/package.json
0 → 100644
1 | +{ | ||
2 | + "_from": "dotenv", | ||
3 | + "_id": "dotenv@8.2.0", | ||
4 | + "_inBundle": false, | ||
5 | + "_integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==", | ||
6 | + "_location": "/dotenv", | ||
7 | + "_phantomChildren": {}, | ||
8 | + "_requested": { | ||
9 | + "type": "tag", | ||
10 | + "registry": true, | ||
11 | + "raw": "dotenv", | ||
12 | + "name": "dotenv", | ||
13 | + "escapedName": "dotenv", | ||
14 | + "rawSpec": "", | ||
15 | + "saveSpec": null, | ||
16 | + "fetchSpec": "latest" | ||
17 | + }, | ||
18 | + "_requiredBy": [ | ||
19 | + "#USER", | ||
20 | + "/" | ||
21 | + ], | ||
22 | + "_resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", | ||
23 | + "_shasum": "97e619259ada750eea3e4ea3e26bceea5424b16a", | ||
24 | + "_spec": "dotenv", | ||
25 | + "_where": "C:\\Users\\김수민\\Desktop\\ostt\\LINEBOT", | ||
26 | + "bugs": { | ||
27 | + "url": "https://github.com/motdotla/dotenv/issues" | ||
28 | + }, | ||
29 | + "bundleDependencies": false, | ||
30 | + "dependencies": {}, | ||
31 | + "deprecated": false, | ||
32 | + "description": "Loads environment variables from .env file", | ||
33 | + "devDependencies": { | ||
34 | + "decache": "^4.5.1", | ||
35 | + "dtslint": "^0.9.8", | ||
36 | + "flow-bin": "^0.109.0", | ||
37 | + "sinon": "^7.5.0", | ||
38 | + "standard": "^13.1.0", | ||
39 | + "standard-markdown": "^5.1.0", | ||
40 | + "standard-version": "^7.0.0", | ||
41 | + "tap": "^14.7.0" | ||
42 | + }, | ||
43 | + "engines": { | ||
44 | + "node": ">=8" | ||
45 | + }, | ||
46 | + "homepage": "https://github.com/motdotla/dotenv#readme", | ||
47 | + "keywords": [ | ||
48 | + "dotenv", | ||
49 | + "env", | ||
50 | + ".env", | ||
51 | + "environment", | ||
52 | + "variables", | ||
53 | + "config", | ||
54 | + "settings" | ||
55 | + ], | ||
56 | + "license": "BSD-2-Clause", | ||
57 | + "main": "lib/main.js", | ||
58 | + "name": "dotenv", | ||
59 | + "repository": { | ||
60 | + "type": "git", | ||
61 | + "url": "git://github.com/motdotla/dotenv.git" | ||
62 | + }, | ||
63 | + "scripts": { | ||
64 | + "dtslint": "dtslint types", | ||
65 | + "flow": "flow", | ||
66 | + "lint": "standard", | ||
67 | + "postlint": "standard-markdown", | ||
68 | + "prerelease": "npm test", | ||
69 | + "pretest": "npm run lint && npm run dtslint", | ||
70 | + "release": "standard-version", | ||
71 | + "test": "tap tests/*.js --100" | ||
72 | + }, | ||
73 | + "standard": { | ||
74 | + "ignore": [ | ||
75 | + "flow-typed/" | ||
76 | + ] | ||
77 | + }, | ||
78 | + "types": "types", | ||
79 | + "version": "8.2.0" | ||
80 | +} |
node_modules/dotenv/types/index.d.ts
0 → 100644
1 | +// TypeScript Version: 3.0 | ||
2 | +/// <reference types="node" /> | ||
3 | + | ||
4 | +export interface DotenvParseOptions { | ||
5 | + /** | ||
6 | + * You may turn on logging to help debug why certain keys or values are not being set as you expect. | ||
7 | + */ | ||
8 | + debug?: boolean; | ||
9 | +} | ||
10 | + | ||
11 | +export interface DotenvParseOutput { | ||
12 | + [name: string]: string; | ||
13 | +} | ||
14 | + | ||
15 | +/** | ||
16 | + * Parses a string or buffer in the .env file format into an object. | ||
17 | + * | ||
18 | + * @param src - contents to be parsed | ||
19 | + * @param options - additional options | ||
20 | + * @returns an object with keys and values based on `src` | ||
21 | + */ | ||
22 | +export function parse( | ||
23 | + src: string | Buffer, | ||
24 | + options?: DotenvParseOptions | ||
25 | +): DotenvParseOutput; | ||
26 | + | ||
27 | +export interface DotenvConfigOptions { | ||
28 | + /** | ||
29 | + * You may specify a custom path if your file containing environment variables is located elsewhere. | ||
30 | + */ | ||
31 | + path?: string; | ||
32 | + | ||
33 | + /** | ||
34 | + * You may specify the encoding of your file containing environment variables. | ||
35 | + */ | ||
36 | + encoding?: string; | ||
37 | + | ||
38 | + /** | ||
39 | + * You may turn on logging to help debug why certain keys or values are not being set as you expect. | ||
40 | + */ | ||
41 | + debug?: boolean; | ||
42 | +} | ||
43 | + | ||
44 | +export interface DotenvConfigOutput { | ||
45 | + error?: Error; | ||
46 | + parsed?: DotenvParseOutput; | ||
47 | +} | ||
48 | + | ||
49 | +/** | ||
50 | + * Loads `.env` file contents into {@link https://nodejs.org/api/process.html#process_process_env | `process.env`}. | ||
51 | + * Example: 'KEY=value' becomes { parsed: { KEY: 'value' } } | ||
52 | + * | ||
53 | + * @param options - controls behavior | ||
54 | + * @returns an object with a `parsed` key if successful or `error` key if an error occurred | ||
55 | + * | ||
56 | + */ | ||
57 | +export function config(options?: DotenvConfigOptions): DotenvConfigOutput; | ||
58 | +/** @deprecated since v7.0.0 Use config instead. */ | ||
59 | +export const load: typeof config; |
node_modules/dotenv/types/test.ts
0 → 100644
1 | +import { config, parse } from "dotenv"; | ||
2 | + | ||
3 | +const env = config(); | ||
4 | +const dbUrl: string | null = | ||
5 | + env.error || !env.parsed ? null : env.parsed["BASIC"]; | ||
6 | + | ||
7 | +config({ | ||
8 | + path: ".env-example", | ||
9 | + encoding: "utf8", | ||
10 | + debug: true | ||
11 | +}); | ||
12 | + | ||
13 | +const parsed = parse("NODE_ENV=production\nDB_HOST=a.b.c"); | ||
14 | +const dbHost: string = parsed["DB_HOST"]; | ||
15 | + | ||
16 | +const parsedFromBuffer = parse(new Buffer("JUSTICE=league\n"), { | ||
17 | + debug: true | ||
18 | +}); | ||
19 | +const justice: string = parsedFromBuffer["JUSTICE"]; |
node_modules/dotenv/types/tsconfig.json
0 → 100644
node_modules/dotenv/types/tslint.json
0 → 100644
... | @@ -130,6 +130,11 @@ | ... | @@ -130,6 +130,11 @@ |
130 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", | 130 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", |
131 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" | 131 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" |
132 | }, | 132 | }, |
133 | + "dotenv": { | ||
134 | + "version": "8.2.0", | ||
135 | + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", | ||
136 | + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" | ||
137 | + }, | ||
133 | "ee-first": { | 138 | "ee-first": { |
134 | "version": "1.1.1", | 139 | "version": "1.1.1", |
135 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", | 140 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", | ... | ... |
발표자료.pptx
deleted
100644 → 0
This file is too large to display.
-
Please register or login to post a comment