mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
changes
This commit is contained in:
parent
b297fcb835
commit
99880fef4d
@ -1,6 +1,5 @@
|
||||
// Module dependencies.
|
||||
var
|
||||
Users = require('../models/users'),
|
||||
var Users = require('../models/users'),
|
||||
ServantMetas = require('../models/servant_metas'),
|
||||
config = require('../../config/config');
|
||||
|
||||
|
||||
13
app/lambda/lambda_one.js
Normal file
13
app/lambda/lambda_one.js
Normal file
@ -0,0 +1,13 @@
|
||||
/**
|
||||
* AWS Lambda Task
|
||||
* - Put tasks in here that take a while to process
|
||||
* - Then will be uploaded to AWS Lambda and executed there
|
||||
*/
|
||||
|
||||
module.exports = function(a, b, callback) {
|
||||
|
||||
var answer = a + b;
|
||||
|
||||
return callback(answer);
|
||||
|
||||
};
|
||||
@ -1,61 +0,0 @@
|
||||
// Module dependencies.
|
||||
var mongoose = require('mongoose'),
|
||||
moment = require('moment'),
|
||||
Schema = mongoose.Schema;
|
||||
|
||||
/**
|
||||
* ProductLink
|
||||
* - Links Etsy Listing ID to a Product ID on Servant
|
||||
*/
|
||||
var ProductLinkSchema = new Schema({
|
||||
etsy_listing_id: {
|
||||
type: String,
|
||||
required: true,
|
||||
trim: true
|
||||
},
|
||||
servant_product_id: {
|
||||
type: String,
|
||||
required: true,
|
||||
trim: true
|
||||
},
|
||||
etsy_user_id: {
|
||||
type: String,
|
||||
required: true,
|
||||
trim: true,
|
||||
unique: true
|
||||
},
|
||||
servant_id: {
|
||||
type: String,
|
||||
required: true,
|
||||
trim: true,
|
||||
unique: true
|
||||
},
|
||||
synced: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Statics
|
||||
*/
|
||||
ProductLinkSchema.statics = {
|
||||
|
||||
/**
|
||||
* Create Product Sync
|
||||
* - Creates a Product Link record in the database
|
||||
*/
|
||||
|
||||
createProductLink: function(etsy_product, servant_product, callback) {
|
||||
var _this = this;
|
||||
|
||||
// First, check if a ProductLink record exists for either product
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
mongoose.model('ProductLink', ProductLinkSchema);
|
||||
@ -2,7 +2,7 @@
|
||||
* ServantMeta Data Model
|
||||
*/
|
||||
|
||||
var dynamoDB = require('../other/aws_client').dynamoDB,
|
||||
var dynamoDB = require('../other/aws_services').dynamoDB,
|
||||
moment = require('moment'),
|
||||
dynamoDBConverter = require('../other/dynamodb_converter'),
|
||||
crypto = require('crypto');
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Users Data Model
|
||||
*/
|
||||
|
||||
var dynamoDB = require('../other/aws_client').dynamoDB,
|
||||
var dynamoDB = require('../other/aws_services').dynamoDB,
|
||||
dynamoDBConverter = require('../other/dynamodb_converter'),
|
||||
crypto = require('crypto');
|
||||
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
var AWS = require('aws-sdk');
|
||||
|
||||
AWS.config.update({
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY,
|
||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
region: "us-east-1"
|
||||
});
|
||||
|
||||
module.exports.dynamoDB = new AWS.DynamoDB();
|
||||
28
app/other/aws_services.js
Normal file
28
app/other/aws_services.js
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* AWS Services
|
||||
* - Config the AWS Client and other Ahere
|
||||
* - Require this into your modules instead of configuring the AWS Client everywhere
|
||||
*/
|
||||
|
||||
var AWS = require('aws-sdk');
|
||||
var lambdaws = require('lambdaws');
|
||||
|
||||
// Config AWS Client
|
||||
AWS.config.update({
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY,
|
||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
region: "us-east-1"
|
||||
});
|
||||
|
||||
// Config Lambdaws Module
|
||||
lambdaws.config({
|
||||
credentials: {
|
||||
accessKey: process.env.AWS_ACCESS_KEY,
|
||||
secretKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
},
|
||||
role: process.env.AWS_LAMBDA_ROLE
|
||||
});
|
||||
|
||||
// Export
|
||||
module.exports.dynamoDB = new AWS.DynamoDB();
|
||||
module.exports.lambdaws = lambdaws;
|
||||
@ -1,3 +1,10 @@
|
||||
/**
|
||||
* DynamoDB Converter
|
||||
* - DynamoDB does not take standard JSON (what the f*ck!)
|
||||
* - Use these to convert DynamoDB results to standard JSON
|
||||
*/
|
||||
|
||||
|
||||
var arrayConverter = function(data_in) {
|
||||
var data_out = [];
|
||||
if (!data_in)
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
"express": "^4.12.3",
|
||||
"forever": "^0.11.1",
|
||||
"jade": "^1.9.2",
|
||||
"lambdaws": "^1.0.15",
|
||||
"lodash": "^2.4.1",
|
||||
"method-override": "^2.3.2",
|
||||
"moment": "^2.9.0",
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
Before Width: | Height: | Size: 125 KiB |
Binary file not shown.
Binary file not shown.
11
server.js
11
server.js
@ -65,6 +65,17 @@ app.use(robots(__dirname + '/robots.txt'))
|
||||
// Routes
|
||||
require('./app/routes')(app); // pass our application into our routes
|
||||
|
||||
/**
|
||||
* Lambda Set-Up
|
||||
* - Upload all Lambda functions on server start so they are ready to be called
|
||||
*/
|
||||
// var lambdaws = require('./app/other/aws_services').lambdaws;
|
||||
|
||||
// var lambda_functions_path = __dirname + '/app/lambda';
|
||||
// fs.readdirSync(lambda_functions_path).forEach(function(file) {
|
||||
// var func = lambdaws.create(require(lambda_functions_path + '/' + file));
|
||||
// });
|
||||
|
||||
// Start Application
|
||||
app.listen(port);
|
||||
console.log('****** Servant Boilerplate ' + env + ' is now running on port ' + port + ' ******'); // shoutout to the user
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user