Skip to content

Instantly share code, notes, and snippets.

View alexandrebodin's full-sized avatar

Alexandre BODIN alexandrebodin

View GitHub Profile
'use strict';
const draftAndPublishSync = require('@strapi/strapi/lib/migrations/draft-publish');
const { hasDraftAndPublish } = require('@strapi/utils').contentTypes;
module.exports = {
/**
* An asynchronous register function that runs before
* your application is initialized.
*
const _ = require("lodash");
const { defineAbility, an } = require("@casl/ability");
const { permittedFieldsOf } = require("@casl/ability/extra");
function Article(attrs) {
Object.assign(this, attrs);
}
const user = {
id: 1,
@alexandrebodin
alexandrebodin / index.js
Created February 14, 2020 10:51
Upload image wiht graphql
import React from "react";
import "./App.css";
import { ApolloProvider } from "@apollo/react-hooks";
import gql from "graphql-tag";
import { ApolloClient } from "apollo-client";
import { createUploadLink } from "apollo-upload-client";
import { InMemoryCache } from "apollo-cache-inmemory";
@alexandrebodin
alexandrebodin / App.js
Created January 23, 2020 20:46
Strapi graphQL upload mutation
import React from "react";
import "./App.css";
import { ApolloProvider } from "@apollo/react-hooks";
import gql from "graphql-tag";
import { ApolloClient } from "apollo-client";
import { createUploadLink } from "apollo-upload-client";
import { InMemoryCache } from "apollo-cache-inmemory";
@alexandrebodin
alexandrebodin / Auth.js
Created June 7, 2019 10:11
Auth custom populate
'use strict';
/**
* Auth.js controller
*
* @description: A set of functions called "actions" for managing `Auth`.
*/
/* eslint-disable no-useless-escape */
const crypto = require('crypto');
@alexandrebodin
alexandrebodin / index.js
Created June 6, 2019 13:55
Uploading images to strapi with react and axios
import React, { Component } from 'react';
import axios from 'axios';
import './App.css';
class App extends Component {
constructor() {
super();
this.state = {
images: [],
FROM node:10.16.0-alpine
RUN apk --no-cache add --virtual native-deps \
g++ gcc libgcc libstdc++ linux-headers autoconf automake make nasm python git && \
npm install --unsafe-perm --quiet node-gyp -g
RUN apk add --no-cache build-base binutils binutils-doc gcc-doc libtool imagemagick imagemagick-dev lcms2 fontconfig freetype zlib-dev
RUN npm install --unsafe-perm -g node-sass
@alexandrebodin
alexandrebodin / index.js
Created August 27, 2018 14:55
ES react
import React from 'react';
import ESClient from './modules/elasticsearch';
const { Provider, Consumer } = React.createContext();
class ES extends React.Component {
constructor(props) {
super(props);
this.client = new ESClient({ index: this.props.index, type: this.props.type });
import React from 'react';
import { observable, action, observe } from 'mobx';
// you can also use class and decorators but that's not really important here
// STORES
const createTodo = title =>
observable(
{
id: uuid(),
@alexandrebodin
alexandrebodin / index.js
Created June 7, 2018 08:32
aggregation_search
import algoliasearch from 'algoliasearch';
const client = algoliasearch('applicationId', 'apiKey');
const index = client.initIndex('indexName');
index.setSettings({
attributesForFaceting: ['someDate']
// other settings
});