Skip to content

teste técnico - API que lê e escreve dados de uma planilha googlesheets.

Notifications You must be signed in to change notification settings

Brunonasccimentto/devtraining

Repository files navigation

Dev Training

Setup

Required node 20.5.0 or higher

Installation

  1. Clone the repository:
$ git clone https://github.com/Brunonasccimentto/devtraining.git
  1. Go to the project folder:
$ cd devtraining
  1. Install the necessary dependencies:
$ npm install
  1. Clone the .env.example file:
$ cp .env.example .env
  1. Make any necessary google cloud settings below.

  2. Start the application:

$ npm run start:dev

Google cloud

To configure your local API with Google Cloud, you can watch this video between time 1:48 and 6:15. With the credentials.json file in the root of the project, you can now run everything.

Spreadsheet

To carry out the tests, you need a spreadsheet with the exact template. To do this, go to here, make a copy to your drive and add the email generated in your Google Cloud to the spreadsheet. Finally, copy the ID from the URL, EXAMPLE:

https://docs.google.com/spreadsheets/d/1XvWJcRLj2WAeXO3ULQ_GxGm9---3SZkjMbGcXMJtt70/edit#gid=0

The ID of this is 1XvWJcRLj2WAeXO3ULQ_GxGm9---3SZkjMbGcXMJtt70. Open the .env file and enter your id.

PORT=3000
SPREADSHEET_ID=1PDe5EntHI7J6Woq0QDoE0dYA-h6d_xyTbxg-dg-Re6U // paste into this variable

Routes

POST api/students/status - update students status

REQUEST
HEADER: not required
BODY (JSON): not required

RESPONSE
STATUS: 200 OK
BODY (JSON):

{
  "message": "The exel table has been updated."
}

STATUS: 500 BAD REQUEST
BODY (JSON):

{
  "error": "Internal server error."
}

GET api/spreadsheet - get json spreadsheet

REQUEST
HEADER: not required
BODY (JSON): not required

RESPONSE
STATUS: 200 OK
BODY (JSON):

{
	"config": {
		"url": "https://sheets.googleapis.com/v4/spreadsheets/1CK_NxArDT5sorTzBh3H7dhV-TBaYIgHH5cRG4DfVok4/values/engenharia_de_software?valueRenderOption=UNFORMATTED_VALUE",
		"method": "GET",
		"userAgentDirectives": [
			{
				"product": "google-api-nodejs-client",
				"version": "7.0.1",
				"comment": "gzip"
			}
		],
		"headers": {
			"x-goog-api-client": "gdcl/7.0.1 gl-node/20.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0RnfjBub07FtvkrOo3_91"
		},
		"params": {
			"valueRenderOption": "UNFORMATTED_VALUE"
		},
		"retry": true,
		"responseType": "unknown"
	},
	"data": {
		"range": "engenharia_de_software!A1:AC1004",
		"majorDimension": "ROWS",
		"values": [
			[
				"Engenharia de Software"
			],
			[
				"Total de aulas no semestre: 60"
			],
			[
				"Matricula",
				"Aluno",
				"Faltas",
				"P1",
				"P2",
				"P3",
				"Situação",
				"Nota para Aprovação Final"
			],
			[
				1,
				"Eduardo",
				8,
				35,
				63,
				61,
				"Exame final",
				5
			],
			[
				2,
				"Murilo",
				8,
				64,
				97,
				36,
				"Exame final",
				4
			],
			[
				3,
				"Guilherme",
				19,
				68,
				74,
				51,
				"Reprovado por falta",
				0
			],
			[
				4,
				"Flavia ",
				23,
				66,
				98,
				62,
				"Reprovado por falta",
				0
			],
			[
				5,
				"Ruan",
				13,
				80,
				65,
				41,
				"Exame final",
				4
			],
			[
				6,
				"Arnando",
				23,
				83,
				68,
				77,
				"Reprovado por falta",
				0
			],
			[
				7,
				"Lucas",
				5,
				38,
				53,
				80,
				"Exame final",
				5
			],
			[
				8,
				"Fabio",
				10,
				53,
				96,
				89,
				"Aprovado",
				0
			],
			[
				9,
				"Alisson",
				15,
				45,
				61,
				68,
				"Exame final",
				5
			],
			[
				10,
				"Felipe",
				12,
				32,
				41,
				85,
				"Exame final",
				5
			],
			[
				11,
				"Rachel",
				11,
				84,
				66,
				39,
				"Exame final",
				4
			],
			[
				12,
				"Jouy",
				13,
				42,
				93,
				57,
				"Exame final",
				4
			],
			[
				13,
				"François",
				19,
				59,
				87,
				89,
				"Reprovado por falta",
				0
			],
			[
				14,
				"Dâmaris",
				10,
				44,
				50,
				62,
				"Exame final",
				5
			],
			[
				15,
				"Leonardo",
				16,
				83,
				92,
				32,
				"Reprovado por falta",
				0
			],
			[
				16,
				"Guilherme ",
				6,
				36,
				38,
				76,
				"Exame final",
				5
			],
			[
				17,
				"Wesley",
				16,
				41,
				52,
				87,
				"Reprovado por falta",
				0
			],
			[
				18,
				"Yuri",
				2,
				87,
				75,
				50,
				"Aprovado",
				0
			],
			[
				19,
				"Kira",
				8,
				36,
				46,
				48,
				"Reprovado por Nota",
				0
			],
			[
				20,
				"Cleici",
				22,
				91,
				88,
				92,
				"Reprovado por falta",
				0
			],
			[
				21,
				"João Moacir",
				23,
				38,
				90,
				98,
				"Reprovado por falta",
				0
			],
			[
				22,
				"Bruno",
				15,
				96,
				37,
				100,
				"Aprovado",
				0
			],
			[
				23,
				"Elcio",
				9,
				73,
				71,
				75,
				"Aprovado",
				0
			],
			[
				24,
				"Criscia",
				0,
				50,
				95,
				84,
				"Aprovado",
				0
			]
		]
	},
	"headers": {
		"alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000",
		"cache-control": "private",
		"content-encoding": "gzip",
		"content-type": "application/json; charset=UTF-8",
		"date": "Thu, 08 Feb 2024 19:05:41 GMT",
		"server": "ESF",
		"transfer-encoding": "chunked",
		"vary": "Origin, X-Origin, Referer",
		"x-content-type-options": "nosniff",
		"x-frame-options": "SAMEORIGIN",
		"x-l2-request-path": "l2-managed-6",
		"x-xss-protection": "0"
	},
	"status": 200,
	"statusText": "OK",
	"request": {
		"responseURL": "https://sheets.googleapis.com/v4/spreadsheets/1CK_NxArDT5sorTzBh3H7dhV-TBaYIgHH5cRG4DfVok4/values/engenharia_de_software?valueRenderOption=UNFORMATTED_VALUE"
	}
}

STATUS: 500 BAD REQUEST
BODY (JSON):

{
  "error": "Internal server error."
}

About

teste técnico - API que lê e escreve dados de uma planilha googlesheets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published