=======
Serverless plugin for integration with kintone.
- Serverless Framework 1.0 or higher
$ npm install https://github.com/ryokdy/serverless-kintone --save
Sorry, This library is not published to npm registry yet. That will be soon.
We strongly recommend to encrypt your api token and password to store them. The feature will be available when "encrypted" flag is "true" in serverless.yml.
You have to create the KMS key beforehand. See AWS document for details.
http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html
Policy example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:Decrypt"
],
"Resource": [
"arn:aws:kms:us-east-1:<your-account-number>:key/<your-key-id>"
]
}
]
}
Command example:
$ aws kms encrypt --key-id alias/my-kms-key --region us-east-1 --plaintext YOUR_TOKEN
provider:
name: aws
runtime: nodejs4.3
plugins:
- serverless-kintone
custom:
kintone:
- name: app1
domain: example.kintone.com
app_id: 15
api_token: <ENCRYPTED_API_TOKEN>
encrypted: true
- name: app2
domain: example.kintone.com
user: user1
password: <ENCRYPTED_PASSWORD>
basic_user: kintone_user
basic_password: <ENCRYPTED_BASIC_PASSWORD>
encrypted: true
- nodejs4.3
get, post, put, delete, upload and download methods are available.
Code example:
- Node.js
'use strict';
const Kintone = require('kintone');
const app = new Kintone('app1');
module.exports.hello = (event, context, callback) => {
const params = {
app: app.appId
};
app.get('/k/v1/records', params).then((res) => {
const response = {
statusCode: 200,
body: JSON.stringify({
records: res.records
}),
};
callback(null, response);
});
};
const app = new Kintone('app1');
const params = {
app: app.appId,
id: 1,
}
app.get('/k/v1/record', params).then((res) => {
const file = res.record.file.value[0];
app.download(file.fileKey, `/tmp/${file.name}`).then((path) => {
console.log(path);
});
});
const app = new Kintone('app1');
app.upload('/tmp/image.png').then((res) => {
const params = {
app: app.appId,
id: 1,
record: {
file: {value: [{fileKey:res.fileKey}]}
}
}
app.put('/k/v1/record', params).then((res) => {
console.log(res.revision);
});
});
MIT License
Copyright(c) Cybozu, Inc.