Skip to content

Instantly share code, notes, and snippets.

View mcnkbr's full-sized avatar

Mertcan Kibar mcnkbr

  • istanbul
View GitHub Profile
@mcnkbr
mcnkbr / serverless.yml
Last active November 14, 2021 22:27
npm install -g serverless
service: hello-world
frameworkVersion: '2'
provider:
name: azure # Serverless sağlayıcı adı
region: West US 2 # Uygulamanın dağıtılacağı lokasyon
runtime: nodejs12 # Nodejs versiyonu
environment:
@mcnkbr
mcnkbr / function.json
Created March 30, 2021 22:09
user-post function.json
{
"bindings": [{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post"
],
"route": "users"
@mcnkbr
mcnkbr / index.js
Created March 30, 2021 22:08
user-post index.js
const userService = require('../services/user');
module.exports = async function(context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
if (req.body && req.body.user) {
context.res = {
status: 200,
body: userService.addUser(context)
};
@mcnkbr
mcnkbr / function.json
Created March 30, 2021 22:03
user-get/function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get"
],
@mcnkbr
mcnkbr / index.js
Created March 30, 2021 22:01
user-get/index.js
const userService = require('../services/user');
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
context.res = {
status: 200,
body: userService.getUsers(context)
};
};
@mcnkbr
mcnkbr / user.js
Created March 30, 2021 21:59
services/user.js
const data = require('./data.js');
module.exports = {
getUsers: function(context) {
try {
const users = data.getUsers();
context.res.status(200).json(users);
} catch (error) {
context.res.status(500).send(error);
}
@mcnkbr
mcnkbr / data.js
Last active March 30, 2021 21:59
services/data.js
const data = {
users: [
{
id: 1,
name: 'user 1',
status: 'approved'
},
{
id: 2,
task: 'user 2',
@mcnkbr
mcnkbr / GenericRepository.cs
Last active February 29, 2024 05:35
Generic Repository and AutoMapper for .NET Entity Framework
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using Common.Extensions;
using AutoMapper;
namespace Repository
{